Skip to content

Any value by type

With the <ValueType> AnyValueByType it is possible to create a PythonPart with de-facto completely dynamic property palette. The parameters are created as a Python list entirely within the script in .py file. A parameter is created using the class AnyValueByType and appended to the list. Here is an example implementation:

<Parameter>
    <Name>AnyValueByTypeList</Name>
    <Text> </Text>
    <Value>[_]<!--(1)!--></Value>
    <ValueType>AnyValueByType</ValueType>
</Parameter>
  1. The parameter is initialized as an empty python list
value : List[AnyValueByType] = build_ele.AnyValueByTypeList.value

if value == []:
    value.append(AnyValueByType("Integer", "Integer value", 1, min_value = "0"))
    value.append(AnyValueByType("Double", "Double value", 1.5, max_value = "10"))
    value.append(AnyValueByType("Length", "Length value", 2000))
    value.append(AnyValueByType("CheckBox", "Checkbox", False))
    value.append(AnyValueByType("StringComboBox", "Language", "German", "German|English|French|Italian"))

And this is how the result may look like:

Parameter AnyValueByType

A possible use case for this kind of parameter could be e.g., creating the palette dynamically based on data read from a file. The base data for the parameter could be read in the create mode and be transformed into the required data class. In the modification mode the data from the PythonPart are used and can be changed.

Placeholder