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>PictureComboBoxValue</Name>
    <Text>Picture|Value=0|Value=1|Value=2</Text> <!--(1)!-->
    <Value>0</Value> <!--(2)!-->
    <ValueList>0|1|2|3</ValueList> <!--(3)!-->
    <ValueList2>param01.png|param02.png|param03.png</ValueList2>
    <ValueType>PictureComboBox</ValueType>
</Parameter>
  1. Here not only the text in the palette left to the combo box is defined, but also the text displayed next to the image. When localizing, remember to specify all corresponding <TextId>s as a list with | separator.
  2. The default value
  3. The corresponding integer value for the image that will be assigned to the parameter after selecting the image.

Picture resource

Just as the Picture ComboBox, but instead of providing a path to a .png file in <ValueList2>, we provide the IDs of Allplan internal image resources.

Parameter Picture Resource ComboBox

<Parameter>
    <Name>PictureResourceComboBoxValue</Name>
    <Text>PictureResource|Value=0|Value=1|Value=2|Value=3</Text>
    <Value>0</Value>
    <ValueList>0|1|2|3</ValueList>
    <ValueList2>16433|16441|16449|14563</ValueList2>
    <ValueType>PictureResourceComboBox</ValueType>
</Parameter>

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

Check out the examples provided in:

  • …\etc\Examples\PythonParts\PaletteExamples\BasicControls\ComboBoxControls.pyp
  • …\etc\PythonPartsExampleScripts\PaletteExamples\BasicControls\ComboBoxControls.py

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