Maya 到具有自定义属性的 fbx

maya to fbx with custom attributes

我有一个 Maya 场景,其中每个网格在我使用 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")

当我导出为 .fbx 并重新导入时,这些属性及其值都消失了。

如何在导出时保留所有这些值?

很遗憾,你不能。来自 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.

您最好的选择可能是尽可能尝试将自定义属性放在非形状节点上,或者探索其他导出格式,例如 alembic 或您自己的自定义格式。