Hi all, I need some help with Animation-related + OpenMaya API help.

I am using OpenMaya to iterate rig controllers I have in my scene, in which 
I am mainly targeting at the rotational attributes.
However I got a snag if the animation data of the controller(s) comes from 
an animation layer.

rig_controls = cmds.ls(selection=True)
m_sel = OpenMaya.MSelectionList()
for ctrl in rig_controls:
    m_sel.add(ctrl)

nodes = []
curves = []
# For each controller
for idx in range(m_sel.length()):
    mfn_dep = OpenMaya.MFnDependencyNode(m_sel.getDependNode(idx))
    plug = mfn_dep.findPlug("rotate", False)
    node_curves = []
    is_valid = False
    # Per Rotate Axis
    for idx, _ in enumerate(["x", "y", "z"]):
        child = plug.child(idx) #eg. <ctrl name>.rotate<x/ y/ z>
        # Assumed locked channels cannot be flipped or fixed easily.
        if child.isLocked:
            is_valid = False
            break
        if OpenMayaAnim.MAnimUtil.isAnimated(child):
            is_valid = True
        # Connect to anim curve
        connected = child.connectedTo(True, False)


        if connected:
            crv = OpenMayaAnim.MFnAnimCurve(connected[0].node())
            # Has actual animation
            if crv.isStatic: #>>> errors if the said curve comes from 
animation layer
                is_valid = False
                break
            node_curves.append(crv)


It will errors out at the `crv.isStatic` line where the error is as 
follows: `# Error: (kFailure): Object does not exist`

Tried looking through the OpenMayaAnim documents but could not find much if 
there is a command that deals with animation being on Animation Layers.
Is there a better way that I can go around with this in which I am trying 
to gather animated rotational values using Maya API?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/ed2865ad-6b75-4326-80c2-247b021cdbfe%40googlegroups.com.

Reply via email to