Creating Attributes


 

An attribute is defined by a name and contains both labels and values. The labels represent the tag for the attribute value such as "Type". The value represents the data that is stored in with the label. For example, the previous sentence described a label of "Type". A value for this label may be "Maple". The value stores the specific information describing the data.

 

C++ VB.NET VBScript
// C++ to Create Attributes
//   lines starting with a // are comments
void WINAPI CreateAtb(charszDllCommandLine)
{
    //  required parameter but unused by this function
    //  circumvent the unreferenced formal parameter warning
    UNUSED_PARAMETER(szDllCommandLine);
 
    //  used for error returns from the API
    short iError;
 
    //  Create the initial attribute values:
    //      In order to create an attribute at least one set of 
    //      label and value must be set.  This data is referenced 
    //      by an index of zero in the attribute definition.  The 
    //      following code adds an attribute definition named 
    //      "MYATB" to the current drawing session and sets the 
    //      initial label to "Type" and value to "Default":
    
    VCAddAtbDef(&iError"MYATB""Type""Default");
 
    //  Set any subsequent label and values in the attribute:
    //      An attribute can contain up to 256 label and value 
    //      sets.  Each of these can represent any set of 
    //      non-graphical data required. Each attribute label and 
    //      value must be set in order. For example, an 
    //      application can set the values for the second record 
    //      set (iRec = 1) and then for the third record set 
    //      (iRec = 2).  It can not skip a set, it must add the 
    //      items in sequential order starting with 0 for the 
    //      initial set.  The following code adds four more label 
    //      and value record sets:
 
    VCSetAtbDefLabelValue(&iError"MYATB""Label1""Value1", 1);
    VCSetAtbDefLabelValue(&iError"MYATB""Label2""Value2", 2);
    VCSetAtbDefLabelValue(&iError"MYATB""Label3""Value3", 3);
    VCSetAtbDefLabelValue(&iError"MYATB""Label4""Value4", 4);
}
' VB.NET to Create Attributes
'   lines starting with an apostrophe are comments
Public Class CreateAtb
 
    ' create Visual CADD object
    Shared WithEvents vcadd As New VCadd32.Automation
 
    Public Shared Function Run(ByVal str As StringAs Integer
 
        '  Create the initial attribute values:
        '      In order to create an attribute at least one set of 
        '      label and value must be set.  This data is referenced 
        '      by an index of zero in the attribute definition.  The 
        '      following code adds an attribute definition named 
        '      "MYATB" to the current drawing session and sets the 
        '      initial label to "Type" and value to "Default":
 
        vcadd.AddAtbDef("MYATB""Type""Default")
 
        '  Set any subsequent label and values in the attribute:
        '      An attribute can contain up to 256 label and value 
        '      sets.  Each of these can represent any set of 
        '      non-graphical data required. Each attribute label and 
        '      value must be set in order. For example, an 
        '      application can set the values for the second record 
        '      set (iRec = 1) and then for the third record set 
        '      (iRec = 2).  It can not skip a set, it must add the 
        '      items in sequential order starting with 0 for the 
        '      initial set.  The following code adds four more label 
        '      and value record sets:
 
        vcadd.SetAtbDefLabelValue("MYATB""Label1""Value1", 1)
        vcadd.SetAtbDefLabelValue("MYATB""Label2""Value2", 2)
        vcadd.SetAtbDefLabelValue("MYATB""Label3""Value3", 3)
        vcadd.SetAtbDefLabelValue("MYATB""Label4""Value4", 4)
 
        ' return
        Return (True)
 
    End Function
 
End Class
' VBScript to Create Attributes
'   lines starting with an apostrophe are comments
 
' create Visual CADD object
set vcadd = CreateObject("VisualCADD.Application.9")
 
'  Create the initial attribute values:
'      In order to create an attribute at least one set of 
'      label and value must be set.  This data is referenced 
'      by an index of zero in the attribute definition.  The 
'      following code adds an attribute definition named 
'      "MYATB" to the current drawing session and sets the 
'      initial label to "Type" and value to "Default":
    
vcadd.AddAtbDef "MYATB""Type""Default"
 
'  Set any subsequent label and values in the attribute:
'      An attribute can contain up to 256 label and value 
'      sets.  Each of these can represent any set of 
'      non-graphical data required. Each attribute label and 
'      value must be set in order. For example, an 
'      application can set the values for the second record 
'      set (iRec = 1) and then for the third record set 
'      (iRec = 2).  It can not skip a set, it must add the 
'      items in sequential order starting with 0 for the 
'      initial set.  The following code adds four more label 
'      and value record sets:
 
vcadd.SetAtbDefLabelValue "MYATB""Label1""Value1", 1
vcadd.SetAtbDefLabelValue "MYATB""Label2""Value2", 2
vcadd.SetAtbDefLabelValue "MYATB""Label3""Value3", 3
vcadd.SetAtbDefLabelValue "MYATB""Label4""Value4", 4
 
' release Visual CADD object
set vcadd = Nothing

 

See Also:

VCAddAtbDef, VCSetAtbDefLabelValue