Message 1 of 2
Get AnimCurve on the object with the attribute from the Animlayer

Not applicable
06-02-2021
08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
For get AnimCurve on the object with the attribute from the Animlayer we need:
1 - select the layer from which you want to get the AnimCurve (BaseAnimation or another)
2 - run Mel or cmds script
*Note - you only need to select one layer, so only one layer should have "selected" and "preferred" attributes activated
nodeName = ["locator1.rx"]
currentLayerSpecifiedAnimCurve = cmds.keyframe( nodeName, query=True, name=True )
print( currentLayerSpecifiedAnimCurve )
#['locator1_rotate_AnimLayer2_inputBX']
But what if we want use OpenMaya for this case
OpenMaya have "MAnimUtil.findAnimation" method, but it return for MPlug "locator1.rx" AnimCurves from all dependend layers, also it return rotateY and rotateZ AnimCurves
nodeName = "locator1"
mSelectionList = OpenMaya.MSelectionList()
mSelectionList.add( nodeName )
nodeMObject = mSelectionList.getDependNode( 0 )
nodeMPlug = OpenMaya.MFnDependencyNode( nodeMObject ).findPlug( "rx", False )
animCurvesMObjectArray = OpenMayaAnim.MAnimUtil.findAnimation( nodeMPlug )
for i in range( animCurvesMObjectArray.__len__() 😞
print( OpenMaya.MFnDependencyNode( animCurvesMObjectArray[i] ).name() )
#locator1_rotate_AnimLayer1_inputBX
#locator1_rotate_AnimLayer1_inputBY
#locator1_rotate_AnimLayer1_inputBZ
#locator1_rotateX
#locator1_rotateY
#locator1_rotateZ
#locator1_rotate_AnimLayer2_inputBX
#locator1_rotate_AnimLayer2_inputBY
#locator1_rotate_AnimLayer2_inputBZ
Also OpenMaya have "OpenMaya.MItDependencyGraph", but result the save as we get from "findAnimation"
nodeName = "locator1"
mSelectionList = OpenMaya.MSelectionList()
mSelectionList.add( nodeName )
nodeMObject = mSelectionList.getDependNode( 0 )
nodeMPlug = OpenMaya.MFnDependencyNode( nodeMObject ).findPlug( "rx", False )
mItDependencyGraph = OpenMaya.MItDependencyGraph( nodeMObject,
OpenMaya.MFn.kAnimCurve,
OpenMaya.MItDependencyGraph.kUpstream,
OpenMaya.MItDependencyGraph.kBreadthFirst,
OpenMaya.MItDependencyGraph.kNodeLevel,
OpenMaya.MItDependencyGraph.kDependsOn)
mItDependencyGraph.resetTo( nodeMPlug,
OpenMaya.MFn.kAnimCurve,
OpenMaya.MItDependencyGraph.kUpstream,
OpenMaya.MItDependencyGraph.kDepthFirst,
OpenMaya.MItDependencyGraph.kPlugLevel,
OpenMaya.MItDependencyGraph.kDependsOn )
while not mItDependencyGraph.isDone():
currentNodeMObject = mItDependencyGraph.currentNode()
depNode = OpenMaya.MFnDependencyNode( currentNodeMObject )
depNodeName = depNode.name()
print( depNodeName )
mItDependencyGraph.next()
#locator1_rotateX
#locator1_rotateY
#locator1_rotateZ
#locator1_rotate_AnimLayer2_inputBX
#locator1_rotate_AnimLayer2_inputBY
#locator1_rotate_AnimLayer2_inputBZ
#locator1_rotate_AnimLayer1_inputBX
#locator1_rotate_AnimLayer1_inputBY
#locator1_rotate_AnimLayer1_inputBZ
So what way, if it exist, by OpenMaya, get result life by Mel or cmds method?