Search code examples
c++mayaautodeskfbx

FBX SDK accessing custom attributes


I have an FBX file that has had custom attributes added in maya. Using the FBX SDK, I am trying to load the mesh and retrieve these attributes.

I have:

FbxNode* lRootNode = lScene->GetRootNode();
    if (lRootNode) {
        for (int i = 0; i < lRootNode->GetChildCount(); i++)
        {
            FbxProperty p = lRootNode->GetChild(i)->FindProperty("UDPMAYA", false);
            if (!p.IsValid())
                std::cout << "found prop" << std::endl;


            PrintNode(lRootNode->GetChild(i));
        }
    }

"UDPMAYA" Could be wrong, i extrapolated from a "UDP3DSMAX" example that I found...

I can't find anything in the docs that explains this, how do I get custom attributes from maya into the fbx sdk?


Solution

  • Like this:

    #define PROPERTY "attribute_name"
    
    FbxMesh* pMesh = (FbxMesh*)pFbxChildNode->GetNodeAttribute();
    
                FbxProperty p = pFbxChildNode->FindProperty(PROPERTY, false);
                if (p.IsValid())
                {
                    std::string nodeName = p.GetName();
    
                    std::cout << "found property: " << nodeName <<std::endl;
    
                }