Scripting

Overview

Kit Core comes with a python interpreter and a scripting system. It is mainly used to write extensions in python, but it can also be used to make simple python scripts. Each extension can register a set of script search folders. Scripts can be run via command line or API.

How to add a script folder

Multiple ways:

  1. Use the /app/python/scriptFolders setting. As with any setting it can be changed in the core config, in the app config, via the command line or at runtime using settings API.

  2. Use IAppScripting API, e.g. carb::getCachedInterface<omni::kit::IApp>()->getPythonScripting()->addSearchScriptFolder("myfolder").

  3. Specify in the extension.toml, in the [[python.scriptFolder]] section:

[[python.scriptFolder]]
path = "scripts"

How to run a script

  1. Command line:

Example: > kit.exe --exec "some_script.py arg1 arg2"  --exec "open_stage"

  1. Settings:

Example: > kit.exe --app/exec/0="some_script.py arg1"

  1. API:

C++ Example: carb::getCachedInterface<omni::kit::IApp>()->getPythonScripting()->executeFile("script.py")

Python Example: omni.kit.app.get_app_interface().get_python_scripting().execute_file("script.py") see (omni.kit.app.IAppScripting.execute_file()) for more details.

Note

The script extension (.py) can be omitted.