简体   繁体   English

Maya python 检查网格是否有 animation

[英]Maya python check if mesh has animation

I'm looping through the selected objects in maya and trying to check if they have either Transform or Deforming animation.我正在遍历 Maya 中的选定对象并尝试检查它们是否具有变换或变形 animation。 Is there a way to check for this?有没有办法检查这个? I found out how to check for the Transform animation, but not sure how to check deformation animation, which would be vertex based animations or bone driven animations.我发现了如何检查变换 animation,但不确定如何检查变形 animation,这将是基于顶点的动画或骨骼驱动的动画。

import maya.cmds as cmds


def hasTransformAnimation(transform):
    if cmds.objExists(transform):
        animAttributes = cmds.listAnimatable(transform)
        for attribute in animAttributes:
            numKeyframes = cmds.keyframe(attribute, query=True, keyframeCount=True)
            if numKeyframes > 0:
                return True
    return False


def hasDeformationAnimation(transform):
    return False



sel = cmds.ls(sl=True, l=True, type=('transform'))
for o in sel:
    print('Transform', o, hasTransformAnimation(o))
    print('Deformation', o, hasDeformationAnimation(o))

I've done this by simply checking if either the transform node has incomming connections to the transformation attributes or if the mesh shape has in incoming connection connected to the inMesh attribute.我通过简单地检查变换节点是否具有到变换属性的传入连接或者网格形状是否具有连接到inMesh属性的传入连接来完成此操作。 The only drawback of this method is that you cannot see if the geometry is really animated or if it is static.这种方法的唯一缺点是您看不到几何图形是否真的是动画的,或者它是否是 static。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM