Layout control
Parameter types described in this section are not intended to pass any values to your script. They all are intended to organize the palette and improve the user experience of the PythonPart.
Expander
Use the expander to group controls within an expander to allow the user to collapse or expand the enclosed controls.
<Parameter>
<Name>Expander</Name>
<Text>Expander</Text>
<Value>False</Value><!--(3)!-->
<ValueType>Expander</ValueType>
<Visible>True</Visible><!--(2)!-->
<Parameter>
<!--(1)!-->
</Parameter>
</Parameter>
- All parameters placed here will appear under this expander.
If no parameters are assigned, the expander will not be displayed. This would
also be the case, if all the parameters are hidden (
<Visible>
tag set to false) Optional
It is possible to hide the expander with all its controls by changing the value of this tag. Read more about controlling the visibility state here.Optional
Setting this tag to True, will result in the expander be shown initially as collapsed. Default is False.
Separator
Use the separator to draw a horizontal line in the palette to separate the controls visually.
Row
Using row it is possible to show multiple controls in one line.
<Parameter>
<Name>Row1</Name>
<Text>Coordinates</Text>
<ValueType>Row</ValueType>
<Parameter>
...
</Parameter>
</Parameter>
Control width
By default, all the controls in a row are given the same width. For some controls it might make sense to make them appear larger.
To achieve that, add the tag <WidthInRow>
to the parameter, whose width
you would like to influence.
<Parameter>
<Name>Row1</Name>
<Text>Coordinates</Text>
<ValueType>Row</ValueType>
<Parameter>
...
<WidthInRow>100</WidthInRow><!--(1)!-->
</Parameter>
</Parameter>
- The width is given in pixel, which will then internally be converted to a relative width. You can expect the value of 100 will make a control take the half of the available width.
You can use advanced logic, when calculating the value, by using the palette layout script
Entire row
It is possible to extend all the controls within the row to the entire palette width, like shown below. This will ignore the default vertical palette division into text on the left, and values on the right side.
To achieve this, add the tag <Value>
to the Row and set it to OVERALL.
<Parameter>
<Name>Row2</Name>
<Text>Second cube</Text>
<Value>OVERALL</Value>
<ValueType>Row</ValueType>
<Parameter>
...
</Parameter>
...
</Parameter>
Control on left side
Normally, the left side of the palette is designated for texts describing the control on the right side.
However, sometimes it might make sense to display a control on the left side e.g., a checkbox that activates
the control on the right side. In this case, add the <Value>
tag to the row, and set its value to OVERALL:_
,
like shown below:
<Parameter>
<Name>NameRow</Name>
<Text>Name</Text>
<ValueType>Row</ValueType>
<Value>OVERALL:1<!--(1)!--></Value>
<Parameter>
<Name>NameCheckBox</Name>
<Text></Text>
<Value>False</Value>
<ValueType>CheckBox</ValueType>
</Parameter>
<Parameter>
<Name>Name</Name>
<Text></Text>
<Value></Value>
<ValueType>String</ValueType>
<Enable>NameCheckBox</Enable>
</Parameter>
</Parameter>
- After the colon, specify how many of the controls inside the row should be shown on the left side. In this case, only the first control (the checkbox) will be shown on the left side of the palette. The string edit field will remain on the right side.
Picture
To place your own picture in the palette, define a picture parameter as follows:
<Parameter>
<Name>Picture</Name>
<Value>PictureForPalette.png</Value><!--(1)!-->
<Orientation>Right</Orientation><!--(2)!-->
<ValueType>Picture</ValueType>
</Parameter>
- The path must be relative to the .pyp file
- The horizontal position of the picture can be manipulated. Possible
values are
Left
,Middle
andRight
To place an Allplan icon in the palette, define a picture parameter as follows:
<Parameter>
<Name>Picture3</Name>
<Value>11851</Value><!--(1)!-->
<Orientation>Middle</Orientation>
<ValueType>Picture</ValueType>
</Parameter>
-
Provide the ID of the picture resource here. Click on the desired icon below - to copy the ID to your clipboard
Text
The value type Text is used to display a Text in the control section (right side) of the property palette. This type of parameter in combination with the parameter Row can be used to create the header of a table like this:
<Parameter>
<Name>FirstText</Name>
<Text></Text>
<Value>X</Value>
<ValueType>Text</ValueType>
</Parameter>
You can control the text alignment by adding the optional tag <Orientation>
:
Left
is the default value.Middle
andRight
are possible.
The texts can be formatted using the tags <FontFaceCode>
and <FontStyle>
, as described
here
Example on GitHub
The implementation of the Text value type is shown in the example Text ( PYP | PY).
Info box
A parameter of your PythonPart may require extensive explanation, but you want to keep the text on the left side of the palette short and simple. In this case, it is a good practice to provide an info box, like shown on the right. To achieve that, provide a row with a dedicated picture resource and your control, like so:
<Parameter>
<Name>NameRow</Name>
<Text>Name</Text>
<ValueType>Row</ValueType>
<Value>OVERALL:1<!--(1)!--></Value>
<Parameter>
<Name>InfoPicture</Name>
<Text>Provide some more extensive explanation here.
Multi-lines are possible.</Text><!--(3)!-->
<TextId>1005</TextId><!--(4)!-->
<Value>AllplanSettings.PictResPalette.eHotinfo<!--(2)!--></Value>
<ValueType>Picture</ValueType>
</Parameter>
<Parameter>
<Name>Name</Name>
<Text></Text>
<Value></Value>
<ValueType>String</ValueType>
</Parameter>
</Parameter>
- Put the picture picture on the left side of the palette (learn more here)
- Use the picture resource id from the PictResPalette class
- This text will not appear in the palette, but only as a tooltip after hovering the mouse over the picture.
- The tooltip can be localized
Layout script
Controlling the layout may require some advanced logic e.g., when calculating the control
widths. You can implement this logic with a python script inside a dedicated tag
<PaletteLayoutScript>
.
<PaletteLayoutScript>
button_width = 22 <!--(1)!-->
default_control_width = 30
min_color_width = 55
control_width_general = AllplanPalette.GetPaletteDataColumnWidth() / 4 <!--(2)!-->
color_width_general = max(min_color_width, control_width_general)
edit_width_general = max(10, (AllplanPalette.GetPaletteDataColumnWidth() - color_width_general) / 3)
</PaletteLayoutScript>
- You can use the tag to define some universal values in one place
- API functions are accessible!
Warning
The script must be left aligned!