Python FBXSDK FbxProperty.Get() not exported to Py? Critical issue

stepan.kment7WW22
Participant
Participant

Python FBXSDK FbxProperty.Get() not exported to Py? Critical issue

stepan.kment7WW22
Participant
Participant

Python FBX SDK - ver currently latest 202032:
I can't access (static) value of the property with Get() - it seems FbxProperty class doesn't have Get() exposed (on the other hand, Set() is exposed properly).
Try this trivial code:

 

import fbx

manager=fbx.FbxManager.Create()

scene=fbx.FbxScene.Create(manager,"scene")

model=fbx.FbxNull.Create(scene,"myModel")
p1 = fbx.FbxProperty.Create(model, fbx.FbxBoolDT, "MyBooleanProperty", "My Bool")
p1.Set(True)     #this works fine and FBX loaded to MoBuilder does have the property and it is set True.
value=p1.Get() #this fails

 

Get() in C++ is documented here:
https://help.autodesk.com/cloudhelp/2020/ENU/FBX-Developer-Help/cpp_ref/class_fbx_property.html#a6b9...

 

confusing is, that getting values of built in properties, such as skeletonJointAttribute.Size.Get() actually DOES work fine, however .Size, .Color etc. appear as object one of subclasses of FbxProperty, not the FbxProperty itself... however any property found by name or created as shown above fails to get data back.

 

I consider this really fatal omission - FBX scenes are built on properties, both user and default, and when the property isn't animated, it is impossible to retrieve its value at the moment - unless I do something wrong.

Any help appreciated!


Kind regards,

Stepan

0 Likes
Reply
683 Views
3 Replies
Replies (3)

ross-g
Participant
Participant

In your example p1 is a fbx.FbxProperty object, you need to convert it to a concrete property type (ie a subclass of FbxProperty) before calling Get.

eg

import fbx
manager = fbx.FbxManager.Create()
scene = fbx.FbxScene.Create(manager, "scene")
model = fbx.FbxNull.Create(scene, "myModel")
p1 = fbx.FbxProperty.Create(model, fbx.FbxGetDataTypeFromEnum(fbx.eFbxBool), "MyBooleanProperty", "My Bool")
p1.Set(True)

value = p1.Get()  # AttributeError: 'FbxProperty' object has no attribute 'Get'

asert fbx.FbxPropertyBool1(p1).Get() == True  # cast property, then get
assert fbx.FbxPropertyString(p1).Get() == "true"  # cast to other types etc

 

It's convenient in Python to just have a mapping of EFbxType enums to the typed FbxProperty subclass.

datatype_map = {
    fbx.eFbxBool: fbx.FbxPropertyBool1,
    ...  # etc
    fbx.eFbxString: fbx.FbxPropertyString,
}
enum_type = prop.GetPropertyDataType().GetType()  # eg fbx.eFbxBool
typed_prop = datatype_map[enum_type](prop)

typed_prop.Get()  # etc
0 Likes

stepan.kment7WW22
Participant
Participant

Hi,

 

thank You so much! Really helpful and I do confirm this solves the problem.

Outstanding question is actuall correct class of the given property for its eType: I managed to match some of them, but not all by far (Nones in the picture) - a matter of fact is in motionBuilder, there are items in the property type enum that aren't found in moBu, such as this Uint, short floats, longlong etc.. hopefully, I'll be fine anyway.

Again, thank You for valuable guidance!
Stepan

 

stepankment7WW22_0-1668095219629.png

 

0 Likes

stepan.kment7WW22
Participant
Participant

so one thing I couldn't get to work is reference type property in MoBuilder - the property that holds a reference to a scene object. There is fbx.FbxReference class this property can be cast to, however the object doesn't expose any meaningful methods to retrieve the node referenced by the property, likely this isn't the right class. There is a fbx scene reference object, however that (imho) serves different purpose, inserts a referenced FBX scene into the main scene. Any idea here, please?
-----
Aside of that, I confirm RGB, RGBA, float, int, enum (including list of options), bool, vectors all do work fine; didn't test time nor timecode.

Thank You,
Stepan

0 Likes