Python Reference Guide
Python Scripting for MotionBuilder 2024 - Reference Guide (pyfbsdk)

Introduction

Welcome To Python Scripting

MotionBuilder provides scripting capabilities based on the Python programming language. By creating and executing scripts, you can automate repetitive tasks.

This document lists the classes and methods available for scripting MotionBuilder using the Python programming language. In this version, we have exposed a subset of the existing Open Reality SDK to Python using an almost identical class hierarchy with some Python specific enhancements and some Python additions (see pyfbsdk_additions.py).

The Open Reality SDK is mainly used to create new interactive tools, custom devices, import/export filters, shaders, and other specialized objects. Since scripting targets different tasks (such as automation, setup, and batch work), the necessary classes to perform some scripting jobs may not yet be available.

Requirements

No additional software is required to use scripting: MotionBuilder includes a minimal Python environment.

Limitations and Restrictions

The Python module is an exposed subset of the Open Reality SDK and uses an almost identical class hierarchy. This introduces the following side effects:

  • The limitations of the C++ Open Reality SDK also applies to code written in Python.

The Python module has the following additional restrictions:

  • The only way C++ code can run Python code is by using FBApplication::ExecuteScript to call already-created Python modules. For more information, see the FBApplication Class Reference in the ORSDK help.
  • Python classes from the SDK cannot serve as parent for a client class, as it will not be possible to overload inherited virtual methods.

Custom modules

In order to use custom Python module, some setup may prove necessary. The simplest setup only requires copying your modules in the folder [APPLICATION]/bin/[platform]/python for regular .py modules. Binary modules, such as .pyd for Windows should be placed in the folder [APPLICATION]/bin/[platform]/python.

Should a different layout be prefered, it will be necessary to use or modify the environment variables PYTHONPATH and PATH. Please refer to the Python documentation for more information.

Class Type

It is possible to determine if an object is of a certain class type using the function Is(int pTypeId) declared in FBPlug. The parameter pTypeId is a FBClassName_TypeInfo() function defined in each class of the Open Reality SDK exposed in Python. Simply replace ClassName with the appropriate class name to get the function for a type of object.

For example:

cube.Is(FBComponent_TypeInfo()) would return True

FBSystem().Is(FBModel_TypeInfo()) would return False

Default Parameter

If a class constructor has one or more default parameters, you must explicitly specify them when calling the constructor.

Future Releases and Feedback

In future releases, we will expand the scope of both the Open Reality SDK and the Python scripting features to answer your requests and requirements.

Your comments and feedback are very much appreciated and will guide further development of both the Open Reality SDK and scripting.

Thank you.

Warning
This Python documentation has been automatically generated directly from the Open Reality C++ SDK documentation. Any errors, omissions or inconsistencies should be reported to ensure that it will be corrected in subsequent versions. Contact and feedback information is in the "Support & Downloads" chapter of the MotionBuilder SDK documentation.

Distribution

Resources

The Open Reality distribution consists of the following:

  • Python Scripting Reference Guide (pyfbsdk)
  • Python Scripting Sample Scripts