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>
<Name>StringComboBox</Name>
<Text>StringComboBox</Text>
<Value>Text1</Value>
<ValueList>Text1|Text2|Text3</ValueList>
<ValueType>StringComboBox</ValueType>
</Parameter>
Integer
<Parameter>
<Name>IntegerComboBox</Name>
<Text>IntegerComboBox</Text>
<Value>1</Value>
<ValueList>1|2|3|4</ValueList>
<ValueType>IntegerComboBox</ValueType>
</Parameter>
Double
<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>
<Name>LengthComboBoxValue</Name>
<Text>LengthComboBox</Text>
<Value>1000</Value>
<ValueList>1000|2000|3000|4000</ValueList>
<ValueType>LengthComboBox</ValueType>
</Parameter>
Angle 1
<Parameter>
<Name>AngleComboBoxValue</Name>
<Text>AngleComboBox</Text>
<Value>45</Value>
<ValueList>0|45|90|180</ValueList>
<ValueType>AngleComboBox</ValueType>
</Parameter>
Picture
Just as the Picture ComboBox, but instead of pointing to an image file you point to an Allplan internal picture resource.
<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>
<ValueList2>12151|12147|12149|12153|12145</ValueList2><!--(5)!-->
<ValueType>PictureResourceComboBox</ValueType>
</Parameter>
- This text appears on the left side of the combo box
- This is the default value
-
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: -
These texts appear next to the picture and can be localized (learn more here)
-
Provide the IDs of the picture resources, separated by
|
. Click on the desired icon below to copy the ID to your clipboard
To create a combo box with icons in the list from your own .png files, set the <ValueType>
to
PictureComboBox.
<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>
- This text appears on the left side of the combo box
- This is the default value
-
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: -
These texts appear next to the picture and can be localized (learn more here)
-
Provide paths to your .png files separated with a pipe character (
|
).
Editable text box
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>
-
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
)
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:
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>
-
Regarding units the same rules apply for a combo box as they apply for a normal edit control ↩↩