Migrating Python Scripts to Plant 3D 2022+
Part of Series: Plant Innovation
- Plant Innovation: Automating Navisworks Publishing
- Building Assemblies to Simplify P&ID Design
- Plant Innovation: Custom Properties in Navisworks
- Project Templates – An Introduction
- Syncing Everything Else in Plant 3D with 360 Sync
- Auxalia PlantExpressTools Off-Page Connector Manager
- Plant Innovation: Project Template Environment Selection
- Migrating Python Scripts to Plant 3D 2022+
- Valves in the Plant 3D Spec Editor
As covered in a previous post about migrating to 2022, AutoCAD Plant 3D has new behavior with how it handles shared content. In addition to loading the larger files like variants.zip, and the metadata folder from within the installation directory (C:\Program Files\Autodesk\AutoCAD 2022\PLNT3D\ContentScripts), Plant 3D now uses Python 3.7 when running custom scripts.
For companies maintaining installations of 2021 or earlier alongside newer versions, you’ll need to duplicate the shared content folder:
To get your Python scripts, you’ll need to migrate your existing script to a new Python version (3.7.9).
You can use a tool like the following to convert the scripts: https://docs.python.org/3.7/library/2to3.html
Once you convert the scripts, put them in the CustomScripts folder (like normal), and run PLANTREGISTERCUSTOMSCRIPTS
After PLANTREGISTERCUSTOMSCRIPTS is run, the standard ScriptGroup.xml, variants.map, and variants.xml will be created.
At the same level as your custom scripts, Plant 3D will create a __pycache__ file which stores the compiled Python by version.
If you have questions about using Plant 3D, contact Applied Software today and talk to an industry expert.