FBX SDK Programmer's Guide > Scripting with Python FBX >

# 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:

- FBX SDK has functions that are overloaded (i.e, there are various versions of the function that share the same function name). In some cases (e.g., FbxProperty::DisconnectAllSrcObjects), some of the overloaded functions are template functions, while others are ordinary functions. In these cases, Python FBX does provide the ordinary functions.
- For each template function in FBX SDK, Python FBX provides a Python version that accepts double parameters and/or returns a double return value. That allows you to also use a float, int, or any other Python data type that can be converted to a double.
- For each template function in FBX SDK, Python FBX does provide a version that accepts str parameters and/or returns a str return value.

An array in C++ becomes a list in Python

In C++, a pointer variable 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* FbxMesh::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.

FbxAnimCurve::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 FbxAnimCurve::KeyAdd looks like this:

    int KeyAdd(FbxTime 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(FbxTime 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:

- int myParameter (to pass an integer value into the function).
- The second int return value (to return the changed integer value).