This section lists the classes and methods in Python that you can use for scripting in MotionBuilder.
MotionBuilder has a Python Editor and Python interpreter. You can write and run Python scripts from within MotionBuilder. You can use Python to customize MotionBuilder and for automating repetitive tasks.
Only a subset of the existing C++ Open Reality SDK is exposed to Python using an almost identical class hierarchy. Some Python specific enhancements and additions are made in the exposed subset of the Open Reality SDK. See the pyfbsdk_additions.py file located in <yourinstallationfolder>. You might not be able to perform certain tasks because the necessary classes might not be available in the exposed subset.
You can refer to the What�s New section for information about the new features and changes related to Python.
You do not have to install any additional software for scripting in Python. MotionBuilder includes a minimal Python environment. If you have installed Python version 2.7.3, it is automatically used for running scripts in MotionBuilder.
Python has the same limitations as the C++ Open Reality SDK because it is an exposed subset of the C++ Open Reality SDK. Additionally, the Python module has the following restrictions:
To use a custom Python module, copy your modules to <yourinstallationfolder>/bin/<platform>/python/lib. You can copy the binary modules, such as .pyd for Windows to <yourinstallationfolder>/bin/<platform>/python/lib/plat-win.
If you prefer a different set up, you can modify the PYTHONPATH and PATH environment variables. Please refer to the Python documentation for more information.
You can determine if an object is of a certain class type by using the function Is(int pTypeId) in the FBPlug class. The parameter pTypeId is a FBClassName_TypeInfo() function that is defined in each class exposed to Python. You can replace ClassName with a class name to determine the class type of the object.
For example:
cube.Is(FBComponent_TypeInfo()) returns True
FBSystem().Is(FBModel_TypeInfo()) returns False
If a class constructor has one or more default parameters, you must specify them when calling the constructor.
The Open Reality distribution consists of the following: