How to define a PythonPart pyp file

Pyp

Pyp files have an XML structure. You can use any tool (Notepad++, Visual Studio) to edit these files.

Minimal pyp definition

The minimal pyp definition must contain at least the <Element> and the <Script> node. The <Script> sub-node defines the link to the corresponding Python script within the <Name></Name> node. The <Title></Title> node defines the title of the PythonParts palette. The <Version></Version> node defines the version of the PythonPart and the <ReadLastInput></ReadLastInput>node defines whether the palette shall be started with the values from the last input (if exist).

The <Interactor> </Interactor node defines whether the scripts is working as interactor with coordinate input functionalities. For more details have a look at the examples in “InteractorExamples”.

<?xml version="1.0" encoding="utf-8"?>

<Element>

    <Script>

        <Name>ContentExamples\Empty.py</Name>

        <Title>Empty</Title>

        <Version>1.0</Version>

        <ReadLastInput>True</ReadLastInput>

        <Interactor>True</Interactor>

    </Script>

</Element>

This generates an empty property palette in Allplan.

Link to Python script

The linked Python script must exist in one of the PythonPartsScripts folders:

ETC\PythonPartsScripts

STD\PythonPartsScripts

PRJ\PythonPartsScripts

If the script is in a subfolder, then this must be added to the script link

        <Name>ContentExamples\Empty.py</Name>

<Page>

To define pages inside within the property palette in Allplan, the <Page> node must be used in the pyp file. All user controls MUST be enclosed in a <Page>.

In the following example, one <Page> is defined without any control. This also results in an empty property palette

<?xml version="1.0" encoding="utf-8"?>

<Element>

    <Script>

        <Name>ContentExamples\Empty.py</Name>

    </Script>

    <Page>

        <Name>Page1</Name>

        <Text>My text in Allplan</Text>

    <!-- empty: no controls added here -->

    </Page>

</Element>

 

When more than one <Page> node is defined, then the property palette will add tab controls.

In the following example, two pages are defined:

<?xml version="1.0" encoding="utf-8"?>

<Element>

    <Script>

        <Name>ContentExamples\Empty.py</Name>

    </Script>

    <Page>

        <Name>Page1</Name>

        <Text>My text page1</Text>

        <!-- empty: no controls added here -->

    </Page>

    <Page>

        <Name>Page2</Name>

        <Text>My text page2</Text>

        <!-- empty: no controls added here -->

    </Page>

</Element>

This results in the following property palette:

<Parameter>

To add parameters to the property palette user controls can be defined by <Parameter> nodes.

 

In the following example a “length” input field is defined. For more information see Length.

 

<?xml version="1.0" encoding="utf-8"?>

<Element>

    <Script>

        <Name>ContentExamples\Empty.py</Name>

    </Script>

    <Page>

        <Name>Page1</Name>

        <Text>My text page1</Text>

       

        <Parameter>

            <Name>Length1</Name>

            <Text>Length</Text>

            <Value>1000.0</Value>

            <ImperialValue>10’5”</ImperialValue>

            <ValueType>Length</ValueType>

        </Parameter>

    </Page>

</Element>

This defines a property palette like:

  

Every <Parameter> node MUST have a unique <Name> node, a <Text> or <TextId> node and a <ValueType> node. On the script side, the corresponding value of the defined parameter can be extracted by using the unique <Name>.

To extract the specified value corresponding to the <Name>Length1</Name> parameter, the following Python statement can be used:

 

length = build_ele.Length1.value

The initial value can be assigned by the node <Value> or <ImperialValue> for imperial units.

 

To get a value list, the value must be initialized like

 

<Value>[1000.] * 5</Value>

 

or

 

<Value>[[0 for x in range(3)] for y in range(5)]</Value>

 

See ETC\Examples\PythonParts\PaletteExamples\ValueList.pyp for more details.

 

There are various examples in the Allplan installation folder ETC\Examples\PythonParts\. Use these examples as a reference, too.

 

<ValueType>Integer</ValueType>

Use the Integer <ValueType> to generate an integer input field. The <Value> tag defines the value. The value does not depend on Allplan unit settings.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My value 1</Text>

            <Value>4711</Value>

            <ValueType>Integer</ValueType>

        </Parameter>

 

<ValueType>Double</ValueType>

Use the Double <ValueType> to generate a double input field. The <Value> tag defines the value. The value does not depend on Allplan unit settings.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My value 1</Text>

            <Value>47.11</Value>

            <ValueType>Double</ValueType>

        </Parameter>

 

<ValueType>Length</ValueType>

Use the Length <ValueType> to generate a length input field. The <Value> tag defines the value in millimeter.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My value 1</Text>

            <Value>4000</Value>

            <ValueType>Length</ValueType>

        </Parameter>

 

The shown value depends on the global Allplan unit setting:

 

<ValueType>Area</ValueType>

Use the Area <Area> to generate a area input field. The <Value> tag defines the value in millimeter².

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My value 1</Text>

            <Value>4000</Value>

            <ValueType>Area</ValueType>

        </Parameter>

 

The shown value depends on the global Allplan unit setting, similar to the length value.

<ValueType>Volume</ValueType>

Use the Volume <Volume> to generate a volume input field. The <Value> tag defines the value in millimeter³.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My value 1</Text>

            <Value>4000</Value>

            <ValueType>Volume</ValueType>

        </Parameter>

 

The shown value depends on the global Allplan unit setting, similar to the length value.

<ValueType>String</ValueType>

Use the String <ValueType> to generate a string input field. The <Value> tag defines the value.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Value1</Name>

            <Text>My string</Text>

            <Value>4, 5, 6, 7</Value>

            <ValueType>String</ValueType>

        </Parameter>

 

<ValueType>Angle</ValueType>

Use the Angle <ValueType> to generate an angle input field. The <Value> tag defines the value. The value must be defined in degrees.

For example: ETC\Examples\PythonParts\PaletteExamples\Hatch.pyp.

        <Parameter>

            <Name>Angle</Name>

            <Text>Angle</Text>

            <Value>45</Value>

            <ValueType>Angle</ValueType>

        </Parameter>

 

 

The shown value depends on the global Allplan unit setting:

 

<ValueType>IntegerComboBox</ValueType>

Use the IntegerComboBox <ValueType> to generate a combo box with integer values. The <Value> tag defines the initial value. The <ValueList> tag defines the possible values. The values of the value list must be separated by the pipe | character. The values do not depend on Allplan unit settings.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>IntegerCombobox</Name>

            <Text>My integer combo box</Text>

            <Value>1</Value>

            <ValueList>1|2|3|4|</ValueList>

            <ValueType>Combobox_Integer</ValueType>

        </Parameter>

 

<ValueType>DoubleComboBox</ValueType>

Use the DoubleComboBox <ValueType> to generate a combo box with double values. The <Value> tag defines the initial value. The <ValueList> tag defines the possible values. The values of the value list must be separated by the pipe | character. The values do not depend on Allplan unit settings.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>DoubleCombobox</Name>

            <Text>My double combo box</Text>

            <Value>1.2</Value>

            <ValueList>1.1|1.2|1.3|1.4</ValueList>

            <ValueType>Combobox_Double</ValueType>

        </Parameter>

 

<ValueType>LengthComboBox</ValueType>

Use the LengthComboBox <ValueType> to generate a combo box with length values. The <Value> tag defines the initial value. The <ValueList> tag defines the possible values in millimeter. The values of the value list must be separated by the pipe | character. The values depend on Allplan unit settings.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>LengthCombobox</Name>

            <Text>My length combo box</Text>

            <Value>2000</Value>

            <ValueList>1000|2000|3000|4000</ValueList>

            <ValueType>Combobox_Length</ValueType>

        </Parameter>

 

 

Shown values depend on the global Allplan unit setting:

 

 

<ValueType>StringCombobox</ValueType>

Use the StringComboBox <ValueType> to generate a combo box with string values. The <Value> tag defines the initial value. The <ValueList> tag defines the possible values. The values of the value list must be separated by the pipe | character.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>StringCombobox</Name>

            <Text>My string combo box</Text>

            <Value>Munich</Value>

            <ValueList>Munich|Paris|London</ValueList>

            <ValueType>Combobox_String</ValueType>

        </Parameter>

 

<ValueType>AngleCombobox</ValueType>

Use the AngleComboBox <ValueType> to generate a combo box with angle values. The <Value> tag defines the initial value. The <ValueList> tag defines the possible values. The values of the value list must be separated by the pipe | character. All values must be defined in degrees.

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>AngleCombobox</Name>

            <Text> My angle combo box </Text>

            <Value>45</Value>

            <ValueList>0|45|90|180</ValueList>

            <ValueType>AngleComboBox</ValueType>

        </Parameter>

 

 

The shown values depend on the global Allplan unit setting:

 

<ValueType>Pen</ValueType>

Use the Pen <ValueType> to generate a pen combo box. The <Value> tag defines the real pen value (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls.pyp.

        <Parameter>

            <Name>Pen</Name>

            <Text>My pen</Text>

            <Value>11</Value>

            <ValueType>Pen</ValueType>

        </Parameter>

 

<ValueType>Stroke</ValueType>

Use the Stroke <ValueType> to generate a stroke combo box. The <Value> tag defines the real stroke value (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls.pyp.

        <Parameter>

            <Name>Stroke</Name>

            <Text>My stroke</Text>

            <Value>90</Value>

            <ValueType>Stroke</ValueType>

        </Parameter>

 

<ValueType>Color</ValueType>

Use the Color <ValueType> to generate a color ID combo box. The <Value> tag defines the real color value (not the index in the combo box).

For example: ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls.pyp.

        <Parameter>

            <Name>Color</Name>

            <Text>My color</Text>

            <Value>11</Value>

            <ValueType>Color</ValueType>

        </Parameter>

 

<ValueType>Layer</ValueType>

Use the Layer <ValueType> to generate a layer combo box. The <Value> tag defines the layer ID (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls.pyp.

        <Parameter>

            <Name>Layer</Name>

            <Text>My layer</Text>

            <Value>3700</Value>

            <ValueType>Layer</ValueType>

        </Parameter>

 

To find the right layer ID, use Allplan layer dialog box.

<ValueType>FaceStyle</ValueType>

Use the FaceStyle <ValueType> to generate a face style combo box. The <Value> tag defines the real face style value (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\FaceStyle.pyp.

        <Parameter>

            <Name>FaceStyle</Name>

            <Text>My face style</Text>

            <Value>480</Value>

            <ValueType>FaceStyle</ValueType>

        </Parameter>

 

<ValueType>Hatch</ValueType>

Use the Hatch <ValueType> to generate a hatch combo box. The <Value> tag defines the real hatch value (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\Hatch.pyp.

        <Parameter>

            <Name>Hatch</Name>

            <Text>My hatch</Text>

            <Value>301</Value>

            <ValueType>Hatch</ValueType>

        </Parameter>

 

<ValueType>Pattern</ValueType>

Use the Pattern <ValueType> to generate a pattern combo box. The <Value> tag defines the real pattern value (not the index in the combo box). If the value is set to -1, the combobox shows the last used setting.

For example: ETC\Examples\PythonParts\PaletteExamples\Pattern.pyp.

        <Parameter>

            <Name>Pattern</Name>

            <Text>My pattern</Text>

            <Value>311</Value>

            <ValueType>Pattern</ValueType>

        </Parameter>

 

<ValueType>Separator</ValueType>

Use the Separator <ValueType> to generate a horizontal separator line.

For example: ETC\Examples\PythonParts\PaletteExamples\Combobox.pyp.

        <Parameter>

            <Name>Separator1</Name>

            <ValueType>Separator</ValueType>

        </Parameter>

 

<ValueType>Expander</ValueType>

Use the Expander <ValueType> to structure palette controls. The <Value> tag defines the collapsed state of the expander. True defines a collapsed expander, False an open expander. If the <Value> tag is missing, then False is used as the default. If the expander has no controls, then it is not shown in the palette.

For example: ETC\Examples\PythonParts\PaletteExamples\Expander.pyp.

        <Parameter>

            <Name>Expander1</Name>

            <Text>My expander</Text>

            <Value>True</Value>

            <!-- Should this expander be collapsed - default: False-->

            <ValueType>Expander</ValueType>

                        … some controls …

        </Parameter>

 

        <Parameter>

            <Name>Expander1</Name>

            <Text>My expander</Text>

            <Value>False</Value>

            <!-- Should this expander be collapsed - default: False-->

            <ValueType>Expander</ValueType>

                        … some controls …

        </Parameter>

 

<ValueType>Row</ValueType>

Use the Row <ValueType> to structure palette controls in one row. If the row has no defined controls or the visible text is empty, then the row does not appear in the palette.

For example: ETC\Examples\PythonParts\PaletteExamples\Row.pyp.

        <Parameter>

            <Name>Row1</Name>

            <Text>My row text</Text>

            <ValueType>Row</ValueType>

                        … some controls …

        </Parameter>

 

<ValueType>CheckBox</ValueType>

Use the CheckBox <ValueType> to define a check box control. The <Value> tag defines the checked state of the check box. True defines a checked box, False an unchecked box.

For example: ETC\Examples\PythonParts\PaletteExamples\Visibility.pyp.

        <Parameter>

            <Name>CheckBox</Name>

            <Text>My checkbox</Text>

            <Value>False</Value>

            <ValueType>CheckBox</ValueType>

        </Parameter>

 

 <Parameter>

            <Name>CheckBox</Name>

            <Text>My checkbox</Text>

            <Value>True</Value>

            <ValueType>CheckBox</ValueType>

        </Parameter>

 

<ValueType>Picture</ValueType>

Use the Picture <ValueType> to define a picture. The <Value> tag defines the picture resource. The resource MUST be in same location as the pyp file. The <Orientation> tag defines the orientation (Left/Middle/Right) of the picture.

For example: ETC\Examples\PythonParts\PaletteExamples\Picture.pyp.

        <Parameter>

            <Name>Picture1</Name>

            <Value>PictureForPalette.png</Value>

            <Orientation>Left</Orientation>

            <ValueType>Picture</ValueType>

        </Parameter>

 

<ValueType>MaterialButton</ValueType>

Use the MaterialButton <ValueType> to define a material button. The <Value> tag defines the material/surface resource. The Allplan STD\Design\ folder is used as the root path for resources.

For example: ETC\Examples\PythonParts\PaletteExamples\MaterialButton.pyp.

        <Parameter>

            <Name>Material</Name>

            <Text>My material</Text>

            <Value>30YearEdition Materialien\\Holzfassaden\\Wood_Boarding_02</Value>

            <DisableButtonIsShown>False</DisableButtonIsShown>

            <ValueType>MaterialButton</ValueType>

        </Parameter>

 

If the material resource doesn’t exist or can’t be found, then the button string is empty:

To define the Disable button, set <DisableButtonIsShown> tag to True:

<ValueType>Button</ValueType>

Use the Button <ValueType> to define a button control. Buttons must be defined in a row (see also Row). The <EventId> tag value is fired as an event to the linked Python script (*.py) file. To react to the event, define the callback function on_control_event in the script file.

For example:

ETC\Examples\PythonParts\PaletteExamples\Buttons.pyp

ETC\PythonPartsScripts\PaletteExamples\Buttons.py

        <Parameter>

            <Name>Row1</Name>      

            <Text>My button</Text>

            <ValueType>Row</ValueType>

 

            <Parameter>

                <Name>Button1</Name>

                <Text>Press me!</Text>

                <EventId>1000</EventId>

                <ValueType>Button</ValueType>

            </Parameter>

        </Parameter>

 

<ValueType>PictureButton</ValueType>

Use the PictureButton <ValueType> to define a picture button control. Buttons must be defined in a row (see also Row). The <EventId> tag value is fired as an event to the linked Python script (*.py) file. For callback handling, see the topic Button. The <Value> tag defines the image resource. The defined image resource MUST be in the same location as the pyp file.

For example:

ETC\Examples\PythonParts\PaletteExamples\Buttons.pyp etc\PythonPartsScripts\PaletteExamples\Buttons.py

        <Parameter>

            <Name>Row2</Name>

            <Text>My picture button</Text>

            <ValueType>Row</ValueType>

 

            <Parameter>

                <Name>Button2</Name>

                <Text></Text>

                <Value>ButtonImageReset16.png</Value>

                <EventId>1001</EventId>

                <ValueType>PictureButton</ValueType>

            </Parameter>

        </Parameter>

 

<ValueType>PictureResourceButton</ValueType>

Use the PictureResourceButton <ValueType> to define a picture button control which uses an Allplan image resource. Buttons must be defined in a row (see also Row). The <EventId> tag value is fired as an event to the linked Python script (*.py) file. For callback handling, see the topic Button. The <Value> tag defines the Allplan image resource ID.

For example:

ETC\Examples\PythonParts\PaletteExamples\Buttons.pyp etc\PythonPartsScripts\PaletteExamples\Buttons.py

        <Parameter>

            <Name>Row3</Name>

            <Text>My picture resource button</Text>

            <ValueType>Row</ValueType>

 

            <Parameter>

                <Name>Button3</Name>

                <Text></Text>

                <Value>17027</Value>

                <EventId>1002</EventId>

                <ValueType>PictureResourceButton</ValueType>

            </Parameter>

        </Parameter>

 

<ValueType>PictureButtonList</ValueType>

Use the PictureButtonList <ValueType> to define a picture button radio control. Buttons must be defined in a row (see also Row). The <Value> tag defines the selected value of the picture button radio group. The <ValueList> tag defines all possible values. The <ValueList2> tag defines the used picture resource files. The resources MUST be in the same location as the pyp file. Values in value lists must be separated by the pipe | character.

For example: ETC\Examples\PythonParts\PaletteExamples\ButtonList.pyp

 

        <Parameter>

            <Name>Row1</Name>

            <Text>Picture button list</Text>

            <ValueType>Row</ValueType>

 

            <Parameter>

                <Name>ButtonList1</Name>

                <Value>0</Value>

                <ValueList>0|1|2</ValueList>

                <ValueList2>param01.png|param02.png|param03.png</ValueList2>

                <ValueType>PictureButtonList</ValueType>

            </Parameter>

        </Parameter>

 

<ValueType>PictureResourceButtonList</ValueType>

Use the PictureResourceButtonList <ValueType> to define a picture button radio control which uses Allplan picture resource IDs. Buttons must be defined in a row (see also Row). The <Value> tag defines the selected value of the picture button radio group. The <ValueList> tag defines all possible values. The <ValueList2> tag defines the used picture resource IDs. Values in value lists must be separated by the pipe | character.

For example: ETC\Examples\PythonParts\PaletteExamples\ButtonList.pyp

 

        <Parameter>

            <Name>Row2</Name>

            <Text>Picture resource button list</Text>

            <ValueType>Row</ValueType>

 

            <Parameter>

                <Name>ButtonList2</Name>

                <Value>1</Value>

                <ValueList>0|1|2|3</ValueList>

                <ValueList2>16433|16441|16449|14563</ValueList2>

                <ValueType>PictureResourceButtonList</ValueType>

            </Parameter>

        </Parameter>

 

<ValueType>RadioButtonGroup</ValueType> and <ValueType>RadioButton</ValueType>

Use the RadioButtonGroup and RadioButton <ValueType> to define a radio button control. The <Value> tag of the RadioButtonGroup defines the selected value of the group. The <Value> tags of the RadioButtons define the set of possible values.

For example: ETC\Examples\PythonParts\PaletteExamples\RadioButtons.pyp

 

        <Parameter>

            <Name>RadioGroup</Name>

            <Text>Color</Text>

            <Value>4</Value>

            <ValueType>RadioButtonGroup</ValueType>

 

            <Parameter>

                <Name>RadioButton1</Name>

                <Text>red</Text>

                <Value>6</Value>

                <ValueType>RadioButton</ValueType>

            </Parameter>

            <Parameter>

                <Name>RadioButton2</Name>

                <Text>green</Text>

                <Value>4</Value>

                <ValueType>RadioButton</ValueType>

            </Parameter>

            <Parameter>

                <Name>RadioButton3</Name>

                <Text>blue</Text>

                <Value>7</Value>

                <ValueType>RadioButton</ValueType>

            </Parameter>

        </Parameter>

 

In Python script, the selected value of the radio button group can be extracted by:

color = build_ele.RadioGroup.value

(RadioGroup is the named ID of the radio button group)

Visibility

Use the <Visible> tag to show or hide controls in the property palette of Allplan. In the example below, the visible status of the Length control depends on the checked state of the CheckBox1 control. The default value of CheckBox1 is False, so the Length control is not visible at first.

For example: ETC\Examples\PythonParts\PaletteExamples\Visibility.pyp

 

        <Parameter>

            <Name>CheckBox1</Name>

            <Text>Check me to the other control </Text>

            <Value>False</Value>

            <ValueType>CheckBox</ValueType>

        </Parameter>

 

        <Parameter>

            <Name>Length</Name>

            <Text>Visibility depends to checkbox state</Text>

            <Value>1</Value>

            <Visible>CheckBox1 == True</Visible>

            <ValueType>Length</ValueType>

        </Parameter>

 

If the check box is checked, then the second control is displayed:

Here are some other logical operator examples:

<Visible>CheckBox1 == True and CheckBox2 == True</Visible>

The visibility depends on two check boxes.

<Visible>Pen > 10 </Visible>

The visibility depends on the integer value of Pen.

<Visible>Pen in {2, 3, 7}</Visible>

The visibility depends on a set of Pen values.

Enable

Use the <Enable> tag to enable or disable controls in the property palette of Allplan. In the shown example, the enable status of the Length control depends on the checked state of the CheckBox1 control. The default value of CheckBox1 is False, so the Length control is disabled at first. For other logical operators, please see the topic Visibility.

For example: ETC\Examples\PythonParts\PaletteExamples\RadioButtons.pyp

 

        <Parameter>

            <Name>CheckBox1</Name>

            <Text>Check me to enable the other control</Text>

            <Value>False</Value>

            <ValueType>CheckBox</ValueType>

        </Parameter>

 

        <Parameter>

            <Name>Length</Name>

            <Text>Enable state depends to checkbox state</Text>

            <Value>1</Value>

            <Enable>CheckBox1 == True</Enable>

            <ValueType>Length</ValueType>

        </Parameter>

 

If the check box is checked, then the second control is enabled:

Uniqueness

All elements which generate a kind of user control (<Page>, <Parameter>) must have a unique name. This unique name is stored in the <Name> node. The text must also be unique per <Page>. If not, then the text is not displayed in the property palette.

The following example uses the same text for both input fields. This results in missing text in the property palette:

    <Page>

        <Name>Page1</Name>

        <Text>My text page1</Text>

       

        <Parameter>

            <Name>Length</Name>

            <Text>Length</Text>

            <Value>1000.</Value>

            <ValueType>Length</ValueType>

        </Parameter>

       

        <Parameter>

            <Name>Length2</Name>

            <Text>Length</Text>

            <Value>1000.</Value>

            <ValueType>Length</ValueType>

        </Parameter>

    </Page>

 

Reinforcement tags

The following value types are special definitions for reinforcement parameters.

<ValueType>ConcreteGrade</ValueType>

Use the ReinfConcreteGrade <ValueType> to generate a reinforcement concrete grade combo box. If the value is set to -1, then the current Allplan value is used.

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfConcreteGrade1</Name>

            <Text>Reinforcement concrete grade</Text>

            <Value>0</Value>

            <ValueType>ReinfConcreteGrade</ValueType>

        </Parameter>

 

<ValueType>ReinfSteelGrade</ValueType>

Use the ReinfSteelGrade <ValueType> to generate a reinforcement steel grade combo box. If the value is set to -1, then the current Allplan value is used.  

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfSteelGrade1</Name>

            <Text>Reinforcement steel grade</Text>

            <Value>3</Value>

            <ValueType>ReinfSteelGrade</ValueType>

        </Parameter>

 

<ValueType>ReinfBarDiameter</ValueType>

Use the ReinfBarDiameter <ValueType> to generate a reinforcement bar diameter combo box.  The possible diameters are defined by the reinforcement steel grade. If the value is set to -1, then the current Allplan value is used.

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfBarDiameter1</Name>

            <Text>Reinforcement bar diameter</Text>

            <Value>10</Value>

            <ValueType>ReinfBarDiameter</ValueType>

        </Parameter>

 

<ValueType>ReinfHookLength</ValueType>

Use the ReinfHookLength <ValueType> to generate a reinforcement hook length edit control. If the value is set to -1, the initial value is calculated by using the constraint values.

For example: ETC\Examples\PythonParts\ReinforcementExamples\HookLengthConstraint.pyp.

        <Parameter>

            <Name>BarHookLength</Name>

            <Text>HookLength</Text>

            <Value>-1</Value>

            <ValueType>ReinfHookLength</ValueType>

            <Constraint>BarDimater;SteelGrade;ConcreteGrade;BarHookAngle;__ReinfHookType__ = BarHookType</Constraint>

        </Parameter>

 

With the constraint values it’s possible to update the hook length if a constraint value is changed. The constraint values are used if they have the ValueType ReinfBarDiameter, ReinfSteelGrade, ReinfConcreteGrade, Angle or ReinfMeshType. It’s also possible to assign a value directly. In this case the format must be __xxx__ = 90, e.g. __Angle__ = 90. The values for __ReinfHookType__ and __ReinfMeshBendingDirection__ must be always assigned.

<ValueType>ReinfMeshGroup</ValueType>

Use the ReinfMeshGroup <ValueType> to generate a reinforcement mesh group combo box. If the value is set to -1, then the current Allplan value is used.  

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfMeshGroup1</Name>

            <Text>Reinforcement mesh group</Text>

            <Value>4</Value>

            <ValueType>ReinfMeshGroup</ValueType>

        </Parameter>

 

<ValueType>ReinfMeshType</ValueType>

Use the ReinfMeshType <ValueType> to generate a reinforcement mesh type combo box. The possible mesh types are defined by the reinforcement mesh group. If the value is set to -1, then the current Allplan value is used.

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfMeshType1</Name>

            <Text>Reinforcement mesh type</Text>

            <Value>R335B</Value>

            <ValueType>ReinfMeshType</ValueType>

        </Parameter>

 

<ValueType>ReinfConcreteCover</ValueType>

Use the ReinfConcreteCover <ValueType> to generate a reinforcement concrete cover combo box.  

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <Name>ReinfConcreteCover1</Name>

            <Text>Reinforcement concrete cover</Text>

            <Value>25</Value>

            <ValueType>ReinfConcreteCover</ValueType>

        </Parameter>

 

<ValueType>ReinfPosition</ValueType>

Use the ReinfPosition <ValueType> to generate a group of reinforcement input controls.  The ID is used to create the name of input parameters like “Diameter1”; “SideLengthStart1” … The possible tags for the input controls are shown in the example. In practice you can combine any of these tags.

For example: ETC\Examples\PythonParts\PaletteExamples\AllControls.pyp.

        <Parameter>

            <ReinfID>1</ReinfID>

            <Picture>PictureForPalette.png</Picture>

            <Diameter>10</Diameter>

            <MeshType>R335B</MeshType>

            <SideLengthStart>0</SideLengthStart>

            <SideLengthEnd>0</SideLengthEnd>

            <Distance>150.</Distance>

            <ValueType>ReinfPosition</ValueType>

        </Parameter>

 

<GeometryExpand>1</GeometryExpand>

If a geometry expansion is implemented within in the PythonPart, then the value of this tag must be set to 1 in order to execute the expansion.

 

Geometry tags

The following value types are special definitions for geometry parameters.

<ValueType>Point2D</ValueType>

Create the input controls for a 2D point.

<ValueType>Point3D</ValueType>

Create the input controls for a 3D point.

<ValueType>Line2D</ValueType>

Create the input controls for a 2D line.

<ValueType>Line3D</ValueType>

Create the input controls for a 3D line.

<ValueType>Vector2D</ValueType>

Create the input controls for a 2D vector.

<ValueType>Vector3D</ValueType>

Create the input controls for a 3D vector.

<ValueType>Arc2D</ValueType>

Create the input controls for a 2D arc.

<ValueType>Arc3D</ValueType>

Create the input controls for a 3D arc.

<ValueType>Polygon2D</ValueType>

Create the input controls for a 2D polygon.

<ValueType>Polygon3D</ValueType>

Create the input controls for a 3D polygon.

<ValueType>Polyline2D</ValueType>

Create the input controls for a 2D polyline.

<ValueType>Polyline3D</ValueType>

Create the input controls for a 3D polyline.

<ValueType>Spline2D</ValueType>

Create the input controls for a 2D spline.

<ValueType>Spline3D</ValueType>

Create the input controls for a 3D spline.

<ValueType>BSpline2D</ValueType>

Create the input controls for a 2D B-Spline.

<ValueType>BSpline3D</ValueType>

Create the input controls for a 3D B-Spline.

<ValueType>Polyhedron3D</ValueType>

Create the input controls for a 3D polyhedron.

<ValueType>BRep3D</ValueType>

Create the input controls for a 3D BRep.

<ValueType>Matrix3D</ValueType>

Create the input controls for a 3D matrix.

 

See ETC\Examples\PythonParts\PaletteExamples\GeometryElementsInput.pyp for more details.

Localization

PythonParts can run with or without localization. Most of the example files are without localization. If a PythonPart is localized, then it has to be localized completely. To find out more about localization, explore the examples ETC\Examples\PythonParts\PaletteExamples\ExampleControls.pyp and ETC\Examples\PythonParts\PaletteExamples\ComboboxLocalisedStringValues.pyp.
PythonParts are using 2 string tables, a global string table for often used strings and the strings of the input function, and the local string table, which is a specific one for the currently used PythonPart.

Global string table

The global string table is stored in the file ETC\PythonPartsScripts\GeneralScripts\Stringtable\BuildingElement_xyz.xml. xyz  will be replaced by the current country code, which depends on the currently used Allplan language.
If the correct file is not available, then the strings of the input function will be displayed in English. Content and localization of the global string table is part of Allplan’s work. The TextIds of the global string table are in the form of “e_XXXX”. The value starts with “e_” and is followed by a sequence of capital letters, numbers and underlines.

Local string table

If a PythonPart is started, then the search for a local string table is started. The file will be searched in the folder of the *.pyp file. The name of the file is *_xyz.xml. xyz will be replaced by the current country code, which depends on the currently used Allplan language, as it is shown above.
For example: If you have a German version of Allplan and you start the PythonPart myPythonPart.pyp, then the localization searches for the myPythonPart_deu.xml file. The Allplan trace window informs you about the success of the file search.
The TextIds of the local string table are numbers within the range of 1000 and 9999.

Minimal string table

The minimal sting table must include at least the <Element> and the <StringTable> node and one item.

<?xml version="1.0" encoding="utf-8"?>

<Element>

    <StringTable>

       <Item>

          <TextId>1001</TextId>

          <Text>Text 1</Text>

       </Item>

    </StringTable>

</Element>

Use of TextIds in the pyp file

The parameters in the pyp file are stored in the following sequence: Parameter, Name, Text. To localize the PythonPart, append the TextId tag after the text tag. You can use all values from the local string table (1000 – 9999) and the global string table e_EXAMPLE.

Standard parameter:

    <Parameter>

        <Name>myName</Name

        <Text>Text 1</Text>

        <TextId>1001</TextId>

    </Parameter>

 

In case of a string combo box, there is a text id for the name of the control, a text id for the value, and a text id for the value list.

Parameter of the string combo box  type:

    <Parameter>

        <Name>myName</Name

        <Text>Name of the control</Text><!—name of the control--!>

        <TextId>1001</TextId>

        <Value>value 1</Value>

        <ValueTextId>1002</ValueTextId>

        <ValueList> rot|blau|grün</ValueList >

        <ValueList_TextIds>1001</ValueList_TextIds>

        <ValueType>1001|1002|1003</TextId>

        <ValueType>Combobox_String</ValueType>

    </Parameter>

Support functions

The following example was modified so that it generates some error output. The pyp file includes 2 TextIds which are not part of the 2 string tables. The palette will inform you about the missing TextIds.

The Allplan trace also informs you about the missing text ids.

BuildingElement Stringtable read file: C:\ProgramData\Nemetschek\2016_Python\2016\ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls_deu.xml

Text Id: e_TEST was not found in the common stringtable:

Text Id: 1001 was not found in stringtable: C:\ProgramData\Nemetschek\2016_Python\2016\ETC\Examples\PythonParts\PaletteExamples\CommonStyleControls_deu.xml

 

This will help you to localize your PythonPart.