Skip to content

Attributes

Attributes are one of the most fundamental information containers in ALLPLAN. Geometrical objects (like wall or 3D-solid) as well as non-geometrical (like project or print layout) have attributes to store information of all kinds. The attribute definitions are stored in following locations:

  • ALLPLAN built-in attributes: ...\etc\xml\AttributeDefinitionCollection_XX.xml
  • User-defined attributes:

    • Office standard attributes: ...\std\xml\AttributeDefinitionCollectionLocal.xml
    • Project attributes: ...\prj\_PROJECT_NAME_\xml\AttributeDefinitionCollectionLocal.xml

Info

Note, that the ALLPLAN built-in attributes are localized (the XX part in the name), whereas the user-defined are not. Therefore, always use Attribute ID when referring to an attribute

Note also, that the user-defined attributes are project-specific! When using these, it is a good practice, to check for and attribute's existence and act accordingly (get its ID or create it). Because they are not localized, the existence check can be based on name.

The most important properties of an attribute are:

  • Attribute-ID: a unique number (integer) used for attribute identification
  • Name: name of the attribute, saying what kind of information it holds (length, volume, etc.)
  • Value type: type of the information an attribute contains (string, integer, etc.)
  • Control type: type of the control used for attribute value input

Tip

To browse through all the attributes and their properties we recommend using the tool AttributeManager located in

...\Prg\AttributManager.exe

Attribute service

Attribute definition access

The service class AttributeService provides access to the existing attribute definitions included in the .xml files mentioned above, e.g.:

  • getting attribute ID for a given attribute name or the other way around
  • getting attribute definition properties such as value type, control type default value(s) or enumeration values (for attributes of type enumeration)

Example

AllplanBaseElements.AttributeService.GetAttributeName(doc, 512)
will return the name of the attribute 512 which is Drawing file number (itbnr)

Attribute selection dialog

The class AttributeService also provides the access to ALLPLAN attribute dialog if it is needed during the workflow independent from the property palette.

Example

dialog_type = AllplanBaseElements.AttributeService.AttributeSelectionDialogType.eInsertAttributes #(3)!
attribute_id = / #(1)!
    AllplanBaseElements.AttributeService.OpenAttributeSelectionDialog(doc, dialog_type) #(2)!
  1. The result will be the ID of the selected attribute.
  2. This line of code will open an attribute selection dialog like this:

    Attribute Selection Dialog

  3. Using this dialog type we ensure, that only editable attributes will be shown in the dialog. Calculated internal attributes (like length) will be hidden. Learn more about possible dialog types here.

Attribute selection dialog

Create new attribute

The class AttributeService also provides the possibility of creating new attribute.

Example

In the following example we create an attribute FixtureHeight with an edit field, minimum, maximum and default values of respectively 1.0, 5.0 and 2.5

attr_list_values =  AllplanUtil.VecStringList() #(1)!
attr_control_type = AllplanBaseElements.AttributeService.AttributeControlType.Edit
attr_type =         AllplanBaseElements.AttributeService.AttributeType.Double

AllplanBaseElements.AttributeService.AddUserAttribute(doc=                      doc,
                                                      attributeType=            attr_type,
                                                      attributeName=            "FixtureHeight",
                                                      attributeDefaultValue=    "2.5",
                                                      attributeMinValue=        1.0, 
                                                      attributeMaxValue=        5.0, 
                                                      attributeDimension=       "m", #(2)!
                                                      attributeCtrlType=        attr_control_type,
                                                      attributeListValues=      attr_list_values)
  1. As the input will be done using an edit field (no combo box), no default values are required.
  2. Unit can be anything (like W/kg or kN/mm²), but defining standard units like volume or weight, take your cue from what is already defined in .xml files.

Example

In the following example we create an attribute FixtureRadius with a combo box as input field, minimum, maximum and default values of respectively 1.0, 1.5 and 1.2

attr_control_type = AllplanBaseElements.AttributeService.AttributeControlType.ComboBox
attr_type =         AllplanBaseElements.AttributeService.AttributeType.Double
attr_list_values =  AllplanUtil.VecStringList()
attr_list_values[:] = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"] #(1)!

AllplanBaseElements.AttributeService.AddUserAttribute(doc=                      doc,
                                                      attributeType=            attr_type,
                                                      attributeName=            "FixtureRadius", 
                                                      attributeDefaultValue=    "1.2", 
                                                      attributeMinValue=        1.0, 
                                                      attributeMaxValue=        1.5, 
                                                      attributeDimension=       "m",
                                                      attributeCtrlType=        attr_control_type,
                                                      attributeListValues=      attr_list_values)
  1. Definition of default values available for selection in the combo box is now necessary.

Warning

Note, that there is no possibility to control, what ID the created attribute becomes. The next free ID will be taken. However, the method AddUserAttribute returns the ID of the newly created attribute, so we can assign it to a variable and refer to it in the script:

attr_ID = AllplanBaseElements.AttributeService.AddUserAttribute(...)

Example

Complete implementation of AttributeService is shown in the example AttributeService ( PYP | PY)

Placeholder