Search code examples
pythonmayafbx

maya to fbx with custom attributes


I have a maya scene where each mesh has a list of custom attributes on the shape node that I add dynamically using python.

import maya.cmds as cmds
import maya.mel as mm

#get mesh objects.
meshes = maya.cmds.ls(type="mesh")
for mesh in meshes:
    cmds.select(mesh)   


    #check if attribute exists, if not, create.
    if not mm.eval( 'attributeExists "test" "%s"' % mesh): 
        cmds.addAttr( shortName='tst', longName='test', dataType="string")

When I export to .fbx and re-import, these attributes and their values are gone.

How can I keep all these values upon export?


Solution

  • Unfortunately, you can't. From the maya docs:

    You can export Maya transform node custom attributes to the user properties of FbxNode. However, you cannot export Maya shape node custom attributes, such as mesh node, to FbxGeometry. This is because FbxGeometry does not currently support user properties.

    Your best bet is probably to try putting the custom attributes on a non-shape node if possible, or else exploring other export formats like alembic or your own custom format.