Scripting in MechworksPDM

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > Scripting in MechworksPDM >

Scripting in MechworksPDM

Support for Python in MechworksPDM

Starting from R25sp0.1, Python is a supported language for scripting.

The extension .py is recognized in the LST_DIR folder and scripts will be shown in the Tools → Utilit menu.
Similarly, in the right mouse button menu on an assembly, part, drawing or project it is possible to add commands creating .py scripts in the LST\(A|P|D|0|G) folder (respectively).

.SPT and .LST files can be Python scripts too: the first line must be a .PY directive (similar to the .VBSCRIPT directive).
Examples of Python scripts are available in the LST_DIR\demo\demo_py folder.

Prerequisites

1.Python must be already installed: suggested version is 3.12. Installing a later version, it is necessary to add in the dbwconn.par the related version using the new parameter: SCRIPT_PYTHON_VERSION

2.PythonNET package must be already installed: via PIP install, check instructions at https://www.activestate.com/resources/quick-reads/pip-install-pythonnet