Parameter with any value by type

The value of the PythonPart parameter can be created as a Python list with an any value for each row. The value type for this is AnyValueByType.

../../../../_images/AnyValueByType.png

Syntax

<Parameter>
<Name>AnyValueByTypeList</Name>
<Text> </Text>
<Value>[_]</Value>
<ValueType>AnyValueByType</ValueType>
</Parameter>

The values in the <Value> tag must be initialized with an empty list like [_] and the list items must be defined by the class

like

value : List[AnyValueByType] = build_ele.AnyValueByTypeList.value

value.append(AnyValueByType("Integer", "Integer value", 1, min_value = "0"))

With this value type it’s possible to create a PythonPart with a partly dynamic property palette. The base data for the parameter can be read in the create mode e. g. from a file and be transformed into the required data class. In the modification mode the data from the PythonPart are used and can be modified.

Optional tags

Sometimes it’s useful to disable or hide the edit fields depending on the value of another parameter. This is achieved by adding additional tags to the parameter or by defining functions in the py-file. See Enable and visible options

The persistent state of the parameter can be changed by adding

<Persistent></Persistent>

Example

The implementation of the AnyValueByType value type is described in the example AnyValueByTypeList, which is located in

…\etc\Examples\PythonParts\PaletteExamples\AnyValueByTypeList.pyp
…\etc\PythonPartsExampleScripts\PaletteExamples\AnyValueByTypeList.py