Skip to content

Script

The .py file is the second essential component of a PythonPart. It contains the python script with the logic of your PythonPart. It is a regular python module containing functions and/or classes. The framework then tries to call these functions or class methods, depending on the situation. What function/method gets called in which situation, depends on the contract you choose to implement. There are three possible contracts, you can choose from, each with a different complexity and different possibilities.

Info

PythonPart framework does not run your script from top to bottom, as if it were the case when you would run it from a command line. Instead, the framework treats your script as a python module and loads it. Then, tries to call certain functions from it.

Contracts

  • Standard PythonPart

    Complexity:
    Possibilities:


    The workflow is predefined and consists of two input steps: input in the property palette and the creation of the element by placing it in the model. Additional input steps, like element selection or point input, cannot be implemented. On the other hand, it requires only two functions to be implemented. Perfect for parametric objects.

    Learn more

  • Interactor PythonPart

    Complexity:
    Possibilities:


    You implement the workflow. It offers 100% freedom regarding workflow steps, their order and types: point input, polyline input, element selection, etc. However, because everything, starting from showing the palette, through the preview generation, ending with element creation, must be implemented in the script, it requires the most effort.

    Learn more

  • Script object PythonPart

    Complexity:
    Possibilities:

    Mixture of both previous contracts. The basic workflow is the same, as in the Standard PythonPart, but it is possible to introduce additional interaction steps (selection, point input, etc...).


    Learn more

Placeholder