Differences between FBX SDK and Python FBX
 
 
 

Python FBX contains most of the classes and member functions that are available in FBX SDK itself. Here are the important differences:

Function templates and class templates not provided

C++ supports function templates. These are functions for which the type of data on which the function operates can be specified as a parameter. Class templates are classes whose member functions can be function templates.

Python does not support templates. Accordingly, Python FBX cannot have classes and functions that correspond to the C++ class templates and function templates. But Python FBX does provide some support:

An array in C++ becomes a list in Python

In C++, a pointer veriable is sometimes used to pass an array as a parameter, or to return an array as a return value. For example, in this C++ function, int* (a pointer to an integer) actually refers to an array of integers:

int* KFbxMesh::GetPolygonVertices();

In FBX Python, this array of integers is converted to a list of type int.

Call by reference becomes an extra return value

In C++, a pointer variable (e.g., int *pLast is sometimes used with a simple type (such as int, float, double) to support call-by-reference. A call-by-reference parameter allow programmers to not only pass a value to a function, but also to return the new value for the parameter (if the function changes it).

In Python, call-by-reference is not supported. But Python does support functions returning tuples (i.e., two return values). C++ does not support tuples as return values.

KFbxAnimCurve::KeyAdd is an example of how Python FBX uses tuples as a replacement for call-by-reference. In the C++ version of FBX SDK, the signature for KFbxAnimCurve::KeyAdd looks like this:

int KeyAdd(KTime pTime, int *pLast);

For this function, int *pLast is used only to return a value from the function, not to pass a value to it. For the Python FBX, the signature has been converted to this:

(int, int) KeyAdd(KTime pTime);

Python FBX has converted int *pLast to a second int return value.

Let’s consider an imaginary C++ function where a pointer variable is used both to pass a value and to return a value:

int imaginaryFunction(int *myParameter);

For Python, the signature would be converted to this:

(int, int) imaginaryFunction(int myParameter);

In this case, Python FBX makes two changes. It converted int *myParameter to: