Parameter with a Python namedtuple

The value of the PythonPart parameter can be created as a Python namedtuple object, defined by the used value types. For each value type a control will be created in the property palette like

../../../../_images/NamedTupleValueBlock.png

Syntax

<Parameter>
<Name>UShape</Name>
<Text>,Diameter,Concrete cover,Top length,Bottom length</Text>
<Value>Param01.png|12|30|1000|2000</Value>
<ValueType>namedtuple(Picture,ReinfBarDiameter,ReinfConcreteCover,Length,Length)</ValueType>
<NamedTuple>
<TypeName>UShape</TypeName>
<FieldNames>Picture,Diameter,Cover,Length1,Length2</FieldNames>
</NamedTuple>
</Parameter>

The values in the <Value> tag must be separated by the pipe | character. This is also required for a used <ValueTextId> tag.

If an empty or only a single text is used for the Text tag, all controls of the namedtuple values are created in one row in the property palette.

<Parameter>
<Name>LShape</Name>
<Text>L Shape</Text>
<Value>14|25|1200</Value>
<ValueType>namedtuple(ReinfBarDiameter,ReinfConcreteCover,Length)</ValueType>
<NamedTuple>
<TypeName>LShape</TypeName>
<FieldNames>Diameter,Cover,Length</FieldNames>
</NamedTuple>
</Parameter>
../../../../_images/NamedTupleValueRow.png

A combination with the Python list is possible. In this case the default values for each row must be separated by the ; character as follows

<Value>
[Param01.png|12|30|1000|2000|;
Param02.png|12|30|1000|2000|;
Param03.png|12|30|1000|2000|]
</Value>

In general, tag data can be split across more than one row, except that the first row’s data must start immediately after the tag.

Define the row text for a list

Each row of the list in the property palette can be provided with its own text. In this case, the first field in the named tuple must be filled with these row text and the value type of this field must be DisplayText.

<Parameter>
<Name>StirrupList</Name>
<Text></Text>
<Value>
[|12|30;
|12|30;
|12|30]
</Value>
<ValueType>namedtuple(DisplayText,ReinfBarDiameter,ReinfConcreteCover)</ValueType>
<NamedTuple>
<TypeName>StirrupList</TypeName>
<FieldNames>RowText.Diameter,Cover</FieldNames>
</NamedTuple>
</Parameter>

The value for the RowText field must be created in the xxx.py file of the PythonPart. The result may look like this

../../../../_images/NamedTupleValueListLineText.png

Hide and disable controls

Sometimes it’s useful to disable or hide controls 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

Depending on the row (in case of a list of namedtuple) and the field name of the namedtuple, the visible and enable state of the control can be returned from the defined functions. The result in the property palette may look like this

../../../../_images/NamedTupleValueList.png

Access to list row values

The special keyword $list_row allows access to tuple values from a row in the tags <Visible>, <Enable>, <MinValue> and <MaxValue>.

Optional tags

All optional tags of the value types specified in <ValueType>namedtuple(…)</ValueType> can be used for the namedtuple parameter. An entry must be created for each value type, separated by a comma , character like

<MinValue> ,,,100,200</MinValue>`

Example

The implementation of the namedtuple value type is described in the example NamedTuple, which is located in

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