Scripting

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 the Main Menu, Window, Scripting Console.

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.


Scripting Console

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.
  • 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
    • Animation
    • Configurations
    • Frames
    • Image
    • Multi-Material
    • XR

View the full list of commands here, or visit the quick start guide.



Scripts

The Scripts tab offer a number of scripting examples that you can run on your scene.

Script location

Scripts are located in the KeyShot Resource folder, e.g. \KeyShot 9\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 luxmath.Vector and luxmath.Matrix respectively.

Import/Edit a script

You may also import a script or edit an existing script using the corresponding buttons on the Scripts tab.