On this page
Quick Start Guide
There are three ways of using scripting:
- Live scripting console
- Scripts in the script library
- Running KeyShot on the command-line:
keyshot.exe (optional file to open) -script <python script file> (optional script arguments..)
The first two are accessed via the scripting console dialog, which is opened via the menu “Window > Scripting Console” or by clicking the scripting console button in the ribbon. In the dialog there are two tabs; “Console” and “Scripts”.
Console
The console is a live python interpreter in which you can input python code to be evaluated.
Note
KeyShot uses Python 3.10 for scripting purposes.
Script Library
The script library contains pre-made script bundled with KeyShot that are either directly useful or provides examples on how to do certain things. It is recommended to take a look in those files to learn more.
General help
In order to get help you can consult the online documentation or you can use the help function.
Additionally, whenever lines appear like the following:
>>> print("Hello, World!") # I am a comment
Hello, World!
Then it symbolizes interaction with the console where “>>>” means python code as input, and otherwise it is output written to the console. Notice the comment after the print. Comments are always ignored by the python interpreter.
There are two main modules for KeyShot scripting; lux
and luxmath
. To print help about the lux
module, do the following:
>>> help(lux)
(several lines omitted..)
It can also be used on functions to understand what they do:
>>> help(lux.pause)
Help on built-in function pause in module lux:
pause(...)
Pauses renderer.