Running Python Scripts

You can run Python scripts when MotionBuilder starts up and while MotionBuilder is running.

Running Python Scripts at Start Up

At start up, MotionBuilder runs Python scripts in the following order:

  1. ToolManager.py in <yourinstallationfolder>\bin\config\Python\ToolManager.py. The Python Tool Manager stores a list of all custom tools that you create using Python. For more information, see Managing Python Tools.
  2. Python scripts in the user folder. For example, C:\Users\<username>\Documents\MB\<year>-x64\config\PythonStartup)
  3. Python scripts in <yourinstallationfolder>\bin\config\PythonStartup
  4. Python scripts in a user defined Python startup folder. To set the user defined Python startup folder, select Settings Preferences Python, and specify a folder in the Python startup folder field.
NOTE:Do not specify a system folder like <yourinstallationfolder>\bin\config\Scripts\UI as the Python startup folder. Some scripts in these folders might not work during start up and can crash MotionBuilder. It is a best practice to create your own folder to save scripts and specify it as the Python startup folder.

The startup folder is added to the Python import path variable (sys.path). You can import functionality from scripts saved here to other scripts. Alternatively, you can also use the Command Line Options to specify which script to run when MotionBuilder starts up.

Executing Python Programs while MotionBuilder is Running

You can run Python scripts within MotionBuilder in the following ways: