Skip to content

Key components

A PythonPart consists of the following essential components:

  • Palette defined in the xxx.pyp file 1
  • Python script provided in the xxx.py file.
  • String resources provided in the xxx_language.xml file

Only the first two components are required for a PythonPart to work.

Property palette

The .pyp file represents the PythonPart property palette. Not only the design of the palette, but also the properties of a PythonPart are defined here e.g., their name, type, default value, etc.

This file can be placed anywhere, but we recommend these folders, so that the PythonPart can be run directly from the Allplan's library:

  • ...\std\Library\PythonParts
  • ...\prj\Library\PythonParts

Script

The .py file contains the Python script for the execution of the PythonPart. At least one .py file must be present, but depending on the complexity the source code can also be split into several files. These must be located in one of the following Allplan folders:

  • ...\std\PythonPartsScripts
  • ...\prj\_project_PythonPartsScripts
  • ...\usr\_username_\PythonPartsScripts

Tip

We recommend using the same subfolder structure which is used for the xxx.pyp file, e.g.:

  • ...\std\Library\PythonParts\Geometry\xxx.pyp
  • ...\std\PythonPartsScripts\Geometry\xxx.py

String resources

The xxx_language.xml file contains texts for the localization of the PythonPart - so called string resources. The texts are used in the property palette of the PythonPart but can also be accessed in the Python script. To indicate, for which language the language file applies, replace language with the appropriate language abbreviation (e.g., MyPythonPart_deu.xml for German).

The location of the xxx_language.xml file must be the same as the location of the .pyp file.

Here is a short sample of an xml file:

<?xml version="1.0"?>
<Element>
  <StringTable>Allplan PythonParts stringtable</StringTable>
  <Item>
    <TextId>1001</TextId>
    <Text>Hallo</Text>
  </Item>
  <Item>
    <TextId>1002</TextId>
    <Text>Guten Tag</Text>
  </Item>
</Element>

Please don't!

Do not use the Allplan folder ...\etc to store any of your files as it is the property of Allplan, and its content can be deleted or moved during an update!


  1. This must not always be the case. The property palette can also be defined in a separate file (we recommend using the .pal extension) especially, if a PythonPart requires more than one palette. But let's keep it simple for now.