4

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',
        ...
})
Elteroooo
  • 2,913
  • 3
  • 33
  • 40
  • 1
    Is this a c++ or python question? The FBX SDK for c++ states GetCharacterLink(..) but also FindCharacterLink(..) with quite a different set of arguments. See http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/index.html?url=cpp_ref/class_fbx_node.html,topicNumber=cpp_ref_class_fbx_node_html6b73528d-77ae-4781-b04c-da4af82b4a08 . You can extract the node names simply by descending down the hierarchy recursively and calling GetName() at every child FBXNode. But I'm not sure if this would solve your problem. – StarShine Aug 21 '15 at 10:21

1 Answers1

2

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))
Elteroooo
  • 2,913
  • 3
  • 33
  • 40