Scripting (Pro feature) allows you to unleash the power of KeyShot for automation, batch processing, and more.
Scripting is available via the Ribbon or from Window > Scripting Console in the main menu.
The Scripting Console enables you to load scripts or input one-line commands inside the python interpreter, located at the bottom of the Console tab. You can also use KeyShot’s predefined scripts or create your own custom scripts inside the Scripts tab.
KeyShot also supports headless scripting, i.e. script execution directly from the terminal without a graphical user interface, you can learn more about this here.
KeyShot scripting uses Python 3.8.
Scripting functionality includes:
- Opening, saving and importing files
- Camera control – Add, get, list, manipulate and save camera.
- Lighting presets – Get, set.
- Materials – Get, set, delete.
- Load/import from .mtl
- Multi-materials – Get, set, create and manipulate.
- Metadata – Get
- Environment – List, set and manipulate.
- Export – Export to gltf, 3mf and usd.
- Geometry – Move, scale, duplicate, show/hide, lock/unlock.
- Model Set – Create, get, set, remove.
- Studios – List, get, set.
- Image styles – List, get, set and manipulate (high level only)
- Rendering – Manipulate render settings, add render passes and add jobs
You can view the full command list or visit the quick start guide here.
The Scripts tab offer a number of scripting examples that you can run on your scene.
Scripts are located in the KeyShot Resource folder, e.g. \KeyShot 10\Scripts. To change this location or add another location, select Edit > Preferences > Folders and change the path for the Scripts folder. Scripts in the folder will be visible in the Scripts tab of the Scripting window.
Creating a Script
To create a script, select Create from the Scripts tab. Provide a name for the script and the author.
If Python 3.8 (64 bit) is installed locally on the machine, KeyShot will detect Python and all installed modules which then can be freely used for scripting in KeyShot (this can be disabled in the General Preferences).
Vector and matrix classes are made available in the
luxmath module to help with doing calculations. They are named
Import/Edit a script
You may also import a script or edit an existing script using the corresponding buttons on the Scripts tab.