Property palette
The definition of the PythonPart parameters and the layout of controls in the palette is defined in the .pyp file. This file has an ordinary XML file structure and can be edited by any text editor, as well as by IDEs like Visual Studio Code or Visual Studio. Here is a short insight of the content of a .pyp file.
<?xml version =”1.0” encoding =”utf-8”?>
<Element>
<LanguageFile>AllControls</LanguageFile> <!--(1)! -->
<Script>
… <!--(2)! -->
</Script>
<Page>
… <!--(3)! -->
</Page>
<Page>
… <!--(4)! -->
</Page>
…
</Element>
-
This tag is optional, and it defines the name and the location of the language file. This allows to use just one language file for multiple PythonParts.
-
In the script node you define the general data of the PythonPart such as the location of the .py file, title or version.
-
The page node collects all the input parameters of the PythonPart, which are displayed in a single page of the property palette.
-
The palette may have more than one page! E.g., to group the input parameters in meaningful sections. In this case a tab control like this is created for each page:
Script node
The script node is used to define the general data of the PythonPart. Here is an example of a script node for a PythonPart AllControls. The values provided in the optional tags are the default ones.
<Script>
<Name>PaletteExamples\AllControls.py</Name> <!--(1)! -->
<Title>AllControls</Title> <!--(2)! -->
<TextId>1001</TextId> <!--(3)! -->
<Version>1.0</Version> <!--(4)! -->
<DataColumnWidth>150</DataColumnWidth> <!--(5)! -->
<ReadLastInput>False</ReadLastInput> <!--(6)! -->
<Interactor>False</Interactor> <!--(7)! -->
<GeometryExpand>False</GeometryExpand> <!--(8)! -->
</Script>
-
Full path to the corresponding .py file. The path must be related to the PythonPartsScripts directory, found in the std or prj path from Allplan. Sub folders can be used and must be separated by the
\
character. -
The title of the PythonPart that is displayed in the property palette.
-
Optional
Text ID of the<Title>
, used for localization of the PythonPart. -
Version number of the PythonPart. Can be used to customize the parameter.
-
Optional
Default width of the data column in the property palette of the PythonPart. -
Optional
If set to True, the parameters of the PythonPart are initialized with the values from the last run -
Optional
It set to True, an Interactor PythonPart would be created -
Optional
If set to True, a geometry expansion will be used for the creation of the reinforcement
Page node
This node collects all the input parameters and controls of the PythonPart.
Here is an example of a <Page>
node definition with all its tags:
<Page>
<Name>FirstPage</Name> <!--(1)! -->
<Text>Page text 1</Text> <!--(2)! -->
<TextId>1001</TextId> <!--(3)! -->
<Visible>True</Visible> <!--(4)! -->
<Enable>True</Enable> <!--(5)! -->
<Parameter>
<!--(6)! -->
</Parameter>
</Page>
-
Name of the page
-
The text entry is used as description for the tab in case of multiple pages.
-
Optional
Text ID of the<Text>
, used for localization of the PythonPart. -
Optional
Value or condition determining, whether to show or hide the whole page in the property palette -
Optional
Value or condition determining, whether to enable or disable the whole page in the property palette -
The
<Parameter>
nodes are used to define the parameters of the PythonPart and the corresponding input controls in the property palette. More about that in this chapter.
If there are no <Paramater>
entries in the <Page>
node, an empty property palette is displayed.
In case of multiple <Page>
nodes, empty page nodes are not displayed.
Tip
Sometimes it might be useful to hide the whole page dynamically, depending on the value of a certain
parameter. This can be done with the tag <Visible>
, which we describe extensively in the
section dynamic property palette.
Hidden page
A special page can be created with the page name __HiddenPage__
. All parameters added to this page are hidden
and can be used to add extra parameters unvisible for the user, but accessible in the script. Use cases for such
parameter are e.g.:
- object UUIDs for selected elements, which are used to retrieve the new element data in the PythonPart modification
- geometry values, needed for the PythonPart modification
- Attributes, which are set in the py file