Skip to content

Combo box

Defining a parameter with a combo box means providing the user of the PythonPart a finite number of possible options to choose from. The <Value> tag defines the default value and the <ValueList> tag defines the possible values of the parameter, separated by | character.

Value types

String

Parameter String ComboBox

<Parameter>
    <Name>StringComboBox</Name>
    <Text>StringComboBox</Text>
    <Value>Text1</Value>
    <ValueList>Text1|Text2|Text3</ValueList>
    <ValueType>StringComboBox</ValueType>
</Parameter>

Integer

Parameter Integer ComboBox

<Parameter>
    <Name>IntegerComboBox</Name>
    <Text>IntegerComboBox</Text>
    <Value>1</Value>
    <ValueList>1|2|3|4</ValueList>
    <ValueType>IntegerComboBox</ValueType>
</Parameter>

Double

Parameter Double ComboBox

<Parameter>
    <Name>DoubleComboBox</Name>
    <Text>DoubleComboBox</Text>
    <Value>1</Value>
    <ValueList>1.0|2.0|3.0|4.0</ValueList>
    <ValueType>DoubleComboBox</ValueType>
</Parameter>

Length 1

Parameter Length ComboBox

<Parameter>
    <Name>LengthComboBoxValue</Name>
    <Text>LengthComboBox</Text>
    <Value>1000</Value>
    <ValueList>1000|2000|3000|4000</ValueList>
    <ValueType>LengthComboBox</ValueType>
</Parameter>

Angle 1

Parameter Angle ComboBox

<Parameter>
    <Name>AngleComboBoxValue</Name>
    <Text>AngleComboBox</Text>
    <Value>45</Value>
    <ValueList>0|45|90|180</ValueList>
    <ValueType>AngleComboBox</ValueType>
</Parameter>

Picture

With a PictureComboBox is used to create a combo box for the input of an integer value by selecting an image from the list.

The <ValueList2> is used to define the image entries of the combo box list. The values are .png file names with path specification.

Parameter Picture ComboBox

<Parameter>
    <Name>IntegerValueList</Name>
    <Text>Integer value list</Text><!--(1)!-->
    <Value>1</Value><!--(2)!-->
    <ValueList>1|2|3</ValueList><!--(3)!-->
    <ValueTextList>Value=1|Value=2|Value=3<!--(4)!--></ValueTextList>
    <ValueList2>..\param01.png|..\param02.png|..\param03.png</ValueList2>
    <ValueType>PictureComboBox</ValueType>
</Parameter>
  1. This text will appear on the left side of the combo box
  2. The value defined here will be selected by default
  3. These integer values correspond with the entries in the box. They must be separated by |. Alternatively, use <EnumList> to define options of enumeration classes instead of integers like:

    <EnumList>AllplanArchEle.VerticalOpeningShapeType.eRectangle|
              AllplanArchEle.VerticalOpeningShapeType.eCircle</EnumList>
    
  4. These texts will appear next to the picture. You can localize them (learn more here)

Example on GitHub

The complete implementation is shown in the example PictureComboBox ( PYP | PY)

Picture resource

Just as the Picture ComboBox, but instead of pointing to an image file you point to an Allplan internal picture resource.

Parameter Picture Resource ComboBox

<Parameter>
    <Name>EdgeOffsetType</Name>
    <Text>Integer value list</Text><!--(1)!-->
    <Value>0</Value><!--(2)!-->
    <ValueList>0|1|2|3|4</ValueList><!--(3)!-->
    <ValueTextList><!--(4)!-->Zero at start|Major value at start|Start equal end|Major value at end|Zero at end</ValueTextList>
    <EnumList2>AllplanSettings.PictResEdgeOffsetType.eZeroAtStart|
                AllplanSettings.PictResEdgeOffsetType.eMajorValueAtStart|
                AllplanSettings.PictResEdgeOffsetType.eStartEqualEnd|
                AllplanSettings.PictResEdgeOffsetType.eMajorValueAtEnd|
                AllplanSettings.PictResEdgeOffsetType.eZeroAtEnd|</EnumList2><!--(4)!-->
    <ValueType>PictureResourceComboBox</ValueType>
</Parameter>
  1. This text will appear on the left side of the combo box
  2. The value defined here will be selected by default
  3. These integer values correspond with the entries in the box. They must be separated by |. Alternatively, use <EnumList> to define options of enumeration classes instead of integers like:

    <EnumList>AllplanArchEle.VerticalOpeningShapeType.eRectangle|
              AllplanArchEle.VerticalOpeningShapeType.eCircle</EnumList>
    
  4. These texts will appear next to the picture. You can localize them (learn more here)

  5. To point out to a picture resource, use one of the dedicated picture resource enumeration classes. These are located in the NemAll_Python_AllplanSettings module and their name begins with PictRes like e.g., PictResEdgeOffsetType

    Alternatively you can use the tag <ValueList2> with internal Allplan IDs, like this:

    <ValueList2>12151|12147|12149|12153|12145</ValueList2>
    

    But currently there is no way to know in advance, what is behind the number.

Example on GitHub

The complete implementation is shown in the example PictureResourceComboBox ( PYP | PY).

Editable text box

Editable ComboBox

It is possible to create a combo box with predefined suggested values, but where the user can still enter his custom value. This custom value is then added into the list of suggested values. This list is saved as a file under the location specified in the <ValueListFile> tag

<Parameter>
    <Name>EditString</Name>
    <Text>String</Text>
    <Value>Munich</Value>
    <ValueList>London|Munich|Paris</ValueList>
    <ValueType>StringComboBox</ValueType>
    <ValueListFile><!--(1)!-->usr\tmp\PypComboSettings\String.val</ValueListFile>
</Parameter>
  1. You, as a developer, can decide where the file should be saved:

    Location Remarks
    usr Recommended The values are user-specific
    prj The values are project-specific
    std The values are office-specific

    Be careful with the last option, since when working with workgroup manager, non-admin users don't have the rights to write anything in std directory which may cause an error.

Dynamic value list

From python code

To generate the options dynamically, the tag <ValueList> can hold Python code, that creates a string with values separated with |, or a Python list. The Python source code for the condition must be left aligned. Functions from the math package are allowed (by calling math.xxx)

<ValueList>['Text'+str(value) for value in range(1, 4)]</ValueList> #(1)!
  1. This line of code will create a list like this: Parameter String ComboBox
<ValueList>
    if HeightDimension == 1:
        return "Text1|Text2|Text3"
    else:
        return "Text4|Text5|Text6"
</ValueList>

From enumeration

The values for the tag <ValueList> can be get from the key in enumeration classes, that already exists in the modules of Allplan Python API. This can be done with this line of code:

<ValueList>"|".join(str(key) for key in AllplanBaseEle.IFC_Version.names.keys())</ValueList>

Instead of full names of Allplan Python API modules, following keywords can be used:

Module full name Keyword
NemAll_Python_AllplanSettings AllplanSettings
NemAll_Python_BaseElements AllplanBaseEle
NemAll_Python_BasisElements AllplanBasisEle
NemAll_Python_Geometry AllplanGeo
NemAll_Python_IFW_Input AllplanIFW
NemAll_Python_Reinforcement AllplanReinf
NemAll_Python_Utility AllplanUtil

Localization

The text that appears in the property palette (<Text>), as well as the entries in the string combo box can both be localized by providing additional tags <TextId> and <ValueList_TextIds>

<Parameter>
    <Name>StringComboBox</Name>
    <Text>StringComboBox</Text>
    <TextId>1001</TextId>
    <Value>Text1</Value>
    <ValueList>Text1|Text2|Text3</ValueList>
    <ValueList_TextIds>1002|1003|1004</ValueList_TextIds>
    <ValueType>StringComboBox</ValueType>
</Parameter>

Example on GitHub

For the complete implementation see the example ComboBoxControls ( PYP | PY).


  1. Regarding units the same rules apply for a combo box as they apply for a normal edit control