My python is rusty but I'll take a shot at it. I have not tested this, its meant to get you started.
import fbx
# Create an FBX manager and scene
manager = fbx.FbxManager.Create()
scene = fbx.FbxScene.Create(manager, "")
# Import the FBX file
importer = fbx.FbxImporter.Create(manager, "")
importer.Initialize("your_fbx_file_path")
importer.Import(scene)
# Get the file name
file_name = importer.GetFileName()
# Get the time length of the animation
animation_length = scene.GetSrcObjectCount(fbx.FbxCriteria.ObjectType(fbx.FbxAnimStack.ClassId))
if animation_length > 0:
animation_length = scene.GetSrcObject(fbx.FbxCriteria.ObjectType(fbx.FbxAnimStack.ClassId), 0).LocalTimeSpan.GetDuration().Get()
# Get the number of bones named "Hips"
bone_count = 0
root_node = scene.GetRootNode()
if root_node:
for i in range(root_node.GetChildCount()):
child_node = root_node.GetChild(i)
if child_node.GetNodeAttribute() and child_node.GetNodeAttribute().GetAttributeType() == fbx.FbxNodeAttribute.eSkeleton:
if child_node.GetName() == "Hips":
bone_count += 1
# Clean up
importer.Destroy()
scene.Destroy()
manager.Destroy()
# Print the results
print("File name:", file_name)
print("Animation length:", animation_length)
print("Number of bones named 'Hips':", bone_count)
I imagine you'd need to replace "your_fbx_file_path" with the file path of your FBX file.
RB Cameron, AIA, LEED AP, EDAC
Digital Practice Leader