Attributes
The value of the PythonPart parameter can be defined as an attribute if an attribute ID is assigned to it. The attribute ID can be defined statically or dynamically.
Static attribute
By setting the <ValueType>
of a parameter to Attribute the value type and the type
of the input control are being automatically determined based on the definition of the
attribute with the ID specified in <AttributeId>
.
As a result, the value in the edit control is being assigned to the parameter value. The value type can be string, integer or float, depending on the data type defined in the attribute.
<Parameter>
<Name>FireRiskFactor</Name>
<Text>Fire risk factor</Text>
<Value>A1</Value>
<ValueType>Attribute</ValueType>
<AttributeId>1398</AttributeId>
</Parameter>
Dynamic attribute
By setting the <ValueType>
of a parameter to AttributeIdValue, an input control for
a dynamic attribute value input is created. It consists of two elements:
- input control for the attribute value on the left,
- button for attribute selection on the right.
Clicking on the button opens the attribute selection dialog. When the attribute is selected, a corresponding input control is created in the palette based on the defined control type of the attribute.
As a result an AttributeIdValue object is being assigned to the parameter value.
<Parameter>
<Name>AttributeID</Name>
<Text>Attribute</Text><!--(1)!-->
<Value>(1398,A2)</Value><!--(2)!-->
<ValueType>AttributeIdValue</ValueType>
<ValueDialog>AttributeSelection</ValueDialog><!--(3)!-->
</Parameter>
- As the actual attribute name is displayed to the left of the control, this tag is ignored.
- The default value must be defined as tuple
(int, Any)
where the fist value is the attribute ID and the second its value. - With the assigned
<ValueDialog>
, the selectable attributes can be limited. See the chapter parameter with dialog.
List of attributes
Using the parameter with value type AttributeIdValue it is also possible to create a dynamic attribute list input. As a result, a list of AttributeIdValue objects is being assigned to the parameter value.
<Parameter>
<Name>DynamicAttributeList</Name>
<Text>Attributes</Text>
<Value>[(0,)]</Value><!--(1)!-->
<ValueType>AttributeIdValue</ValueType>
<ValueDialog>AttributeSelection</ValueDialog>
</Parameter>
- By defining the default value as a Python list, the user can select more than one attribute.
Clicking to the button displayed to the right of the control can be used to:
- add a new attribute to the list,
- remove an attribute from the list.
Dynamic attribute ID
By setting the <ValueType>
of a parameter to AttributeID it is possible to create an input
control for just an ID of an attribute. In the palette, the attribute name is shown to the user.
As a result an integer representing the ID is being assigned to the parameter value.
<Parameter>
<Name>AttributeID</Name>
<Text>All attributes ID</Text>
<Value></Value>
<ValueType>AttributeID</ValueType>
<ValueDialog>AttributeSelection</ValueDialog> <!--(1)!-->
</Parameter>
- With the assigned
<ValueDialog>
, the selectable attributes can be limited. See the chapter parameter with dialog.
The button on the right opens the attribute selection dialog.
Dialog
List of attribute IDs
Using the parameter with value type AttributeId it is also possible to create an input control for a list with attribute IDs. As a result an list of integers representing the IDs is being assigned to the parameter value.
<Parameter>
<Name>AttributeIDFilter</Name>
<Text>Attributes</Text>
<Value>[0]</Value> <!--(1)!-->
<ValueType>AttributeId</ValueType>
<ValueDialog>AttributeSelection</ValueDialog>
</Parameter>
- By defining the default value as a Python list, the input control now allows the user to select more than one attribute.
The button on the right opens the attribute selection dialog.
Dialog
Additional tags
All additional tags, that can be set for a regular edit control, can also be set for a control that is assigned to an attribute. Please refer to the section additional tags in the chapter parameter with edit controls.