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:
ToolManager.py in
\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. Python scripts in the user folder. For example, C:\Users\{username}\Documents\MB\{version}\config\PythonStartup
Python scripts in
\bin\config\PythonStartup 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.
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:
Run individual commands and Python scripts in the Python Editor's interactive console, or using the Python Telnet Console.
Bind Python scripts to a keyboard shortcut. For more information, see Managing Python Tools.
Run Python scripts from the Asset Browser using a custom path (right click in the navigation tree). When you drag and drop from the Asset Browser to the scene, you are prompted to execute, add to the scene, or both. Adding to the scene makes it accessible in the Navigator under Scripts.
Run Python scripts through MotionBuilder's C++ API function
FBApplication::ExecuteScript().