Skip to content

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.

Expander

<Parameter>
    <Name>Expander</Name>
    <Text>Expander</Text>
    <Value>False</Value><!--(3)!-->
    <ValueType>Expander</ValueType>
    <Visible>True</Visible><!--(2)!-->

    <Parameter>
    <!--(1)!-->
    </Parameter>
</Parameter>
  1. 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)
  2. 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.
  3. Optional Setting this tag to True, will result in the expander be shown initially as collapsed. Default is False.

Example on GitHub

See the example Expander ( PYP | PY).

Separator

Use the separator to draw a horizontal line in the palette to separate the controls visually.

Separator

<Parameter>
    <Name>Separator</Name>
    <ValueType>Separator</ValueType>
</Parameter>

Row

Using row it is possible to show multiple controls in one line.

Row

<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.

Row with unequal control width

Row with equal control width

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>
  1. 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.

Row over the entire palette width

Default

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

Control on the left

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>
  1. 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.

Example on GitHub

See the example Row ( PYP | PY) for a p.

Picture

To place your own picture in the palette, define a picture parameter as follows:

Picture

<Parameter>
    <Name>Picture</Name>
    <Value>PictureForPalette.png</Value><!--(1)!-->
    <Orientation>Right</Orientation><!--(2)!-->
    <ValueType>Picture</ValueType>
</Parameter>
  1. The path must be relative to the .pyp file
  2. The horizontal position of the picture can be manipulated. Possible values are Left, Middle and Right

To place an Allplan icon in the palette, define a picture parameter as follows:

Picture resource

<Parameter>
    <Name>Picture3</Name>
    <Value>11851</Value><!--(1)!-->
    <Orientation>Middle</Orientation>
    <ValueType>Picture</ValueType>
</Parameter>
  1. Provide the ID of the picture resource here. Click on the desired icon below - to copy the ID to your clipboard

      Page 1/0

    Example on GitHub

    The example implementation is shown in the example Picture ( PYP | PY).

    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:

    Text

    <Parameter>
        <Name>FirstText</Name>
        <Text></Text>
        <Value>X</Value>
        <ValueType>Text</ValueType>
    </Parameter>
    

    Text

    You can control the text alignment by adding the optional tag <Orientation>:

    <Orientation>Left<!--(1)!--></Orientation>
    
    1. Left is the default value. Middle and Right 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

    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>
    
    1. Put the picture picture on the left side of the palette (learn more here)
    2. Use the picture resource id from the PictResPalette class
    3. This text will not appear in the palette, but only as a tooltip after hovering the mouse over the picture.
    4. 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>
    
    1. You can use the tag to define some universal values in one place
    2. API functions are accessible!

    Warning

    The script must be left aligned!

    Example on GitHub

    The example implementation of palette layout script is shown in the example Row ( PYP | PY).

    Placeholder