FBX SDK - Get the FbxNode from an ENodeId of a Character

1k views Asked by At

Is it possible to get the associated FbxNode from the enum ENodeId ? for example if i want to get the FbxNode from the Character::eLeftHand

I tried to use Character::GetCharacterLink(ENodeId, FbxCharacterLink) then extracting the FbxNode from FbxCharacterLink simply by calling FbxCharacterLink::mNode

However this function returns for most ENodeIds False, so no FbxCharacterLink is created.

character = myScene.GetCharacter(0)
lefthand = character.eLeftHand
lefthand_node = FbxCharacterLink()
character.GetCharacterLink(lefthand, lefthand_node) # False
lefthand_node = lefthand_node.mNode

when I was scripting inside Motionbuilder using Python and Pyfbxsdk, it was very easy, no matter how the skeleton objects are named, I can get the FBXObject of it

m = character.GetModel(self.BodyNodeObject[o])

and BodyNodeObject is generated with

def BodyNodes(self):
    for i in dir(FBBodyNodeId):
        if i[0] == 'k':
            try:
                self.BodyNodeObject[BodyNodesId[i]] = getattr(FBBodyNodeId, i)
            except:
                pass

BodyNodesId is simply a dictionary

BodyNodesId = OrderedDict({
        'kFBChestNodeId':'Spine1',
        'kFBHeadNodeId':'Head',
        'kFBHipsNodeId':'Hips',
        'kFBLeftAnkleNodeId':'LeftFoot',
        'kFBLeftCollarNodeId':'LeftShoulder',
        'kFBLeftElbowNodeId':'LeftForeArm',
        ...
})
1

There are 1 answers

0
Elteroooo On BEST ANSWER

this worked for me

from fbx import *

for i in range(myscene.GetCharacterCount()):
    character = myscene.GetCharacter(i)
    node = character.eHips
    link = FbxCharacterLink()
    while (character.GetCharacterLink(node, link)):
        print node, link.mNode.GetName()
        node = character.ENodeId(int(node+1))