Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[2020.3.7][Linux] FBX PythonBindings + Python 3.11 issues with FbxAxisSystem

1 REPLY 1
Reply
Message 1 of 2
pawelb91
291 Views, 1 Reply

[2020.3.7][Linux] FBX PythonBindings + Python 3.11 issues with FbxAxisSystem

Hey everyone!

 

I'm using FBX SDK + Python Bindings with Unreal Engine. The latest version comes with Python 3.11.

Unfortunately some of my code no longer works - this is the primary suspect https://github.com/python/cpython/issues/100458.

 

In previous Python versions I used to create an FbxAxisSystem object by passing integers to the constructor.

Example: 

 

FbxAxisSystem(3, -2, 1)

 

 

 Python 3.11 however demands enums. And it's fine and below code works ok:

 

 

FbxAxisSystem(FbxAxisSystem.EUpVector.eZAxis, FbxAxisSystem.EFrontVector.eParityOdd, FbxAxisSystem.ECoordSystem.eLeftHanded)

 

 

The issue is that there are no negative counterparts for these enums. Currently there is no way to specify a sign when passing an argument.

Adding a sign before the enum also doesn't work anymore:

 

 

FbxAxisSystem(-FbxAxisSystem.EUpVector.eZAxis,...,...)

 

 

I noticed in SDK header files a static function in fbxaxissystem.h that could do the job, but it looks like it's not supported by sip most likely. It cannot be used from python code.

 

 

static bool ParseAxisSystem(const char * pAxes, FbxAxisSystem& pOutput);

 

 

Does anyone else have the same issue and perhaps a possible solution or workaround?

I guess the easiest way to address this would be to just expand the enums if Autodesk team got involved.

 

 

enum EFrontVector
{
    eParityEven = 1,
    eParityOdd = 2
};
||
\/
enum EFrontVector
{
    eParityOddNegative = -2,
    eParityEvenNegative = -1,
    eParityEven = 1,
    eParityOdd = 2
};

 

 

 

1 REPLY 1
Message 2 of 2
pawelb91
in reply to: pawelb91

Ok, nevermind. I've found a workaround.

There are 2 possible ways to deal with this. Just have to edit one or two files before installing the bindings (python -m pip install . ).

 

1) Edit file fbxaxissystem.sip in the Python Bindings sip directory, add 2 lines:

 

FbxAxisSystem(); // This one
FbxAxisSystem(EUpVector pUpVector, EFrontVector pFrontVector, ECoordSystem pCoorSystem);
FbxAxisSystem(const FbxAxisSystem& pAxisSystem);
FbxAxisSystem(const EPreDefinedAxisSystem pAxisSystem);
static bool ParseAxisSystem(const char * pAxes, FbxAxisSystem& pOutput); // And this one
virtual ~FbxAxisSystem();

 

After installing the bindings, the ParseAxisSystem(...) function will be properly bound and available. Could be used like this:

 

...
axis_system = FbxAxisSystem()
FbxAxisSystem.ParseAxisSystem("xyz", axis_system)
up_vector = axis_system.GetUpVector()
...

 

It works fine, it allows negative vectors but I'm yet to figure out how to properly get desired output from the string 🙂

 

2) The second one is actually the one I proposed in my original post - expanding the enums. I tried it before and it didn't work, but turns out I forgot to update *.sip file as well. So, what you need to do is just expand the desired enums in both <python_bindings_path>/sip/fbxaxissystem.sip and <fbx_sdk_path>/include/fbxsdk/scene/fbxaxissystem.h. Example with EFrontVector:

 

enum EFrontVector
{
    eParityOddNegative = -2, # Add this line
    eParityEvenNegative = -1, # Add this line
    eParityEven = 1,
    eParityOdd = 2
};

 

After installing the bindings, the new values can be used in FbxAxisSystem(...) constructor and are working as expected.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report