AnimLayers pain

311 views
Skip to first unread message

Lidia Martinez

unread,
Mar 24, 2016, 1:38:53 AM3/24/16
to python_in...@googlegroups.com
Hi all!,

animLayers python command is pretty bad in general. Docs are wrong, for most of the params. I sent suggestions to Autodesk. They normally fix it... but it's annoying.


I want to find the animation curves for an node. If it happens to be inside an anim layer... the party starts:



The problem is I only have these options:

A) mc.animLayer( layer, animCurves=True, q=1)   
B) mc.animLayer( [object], affectedLayers=True, q=1)
C) mc.animLayer( layer, blendNodes=True, q=1)

A)  Returns ALL THE ANIM CURVES for ALL CHANNELS for ALL OBJECTS in the scene.  (????  insane).  They can be thousands of strings.

B)  It returns which layers the object is in. 
NOTE: the docs don't tell you about that list... weird.

C)  Gets the blending nodes FOR ALL CHANNELS for ALL OBJECTS in that layer. These ones connect the animations and the original node. They can be hundreds.

So that's all I have...

Crazy stuff. I get a list of 5000 strings. And we all know how fast strings are. And considering how python manages memory in terms of growing lists and then deleting the contents...

And I have to do that... for every object I have.




I'll end up using my stupid algorithm that travels through the blend nodes to find the animations... which is obviously buggy, too, and has special cases everywhere. 




Any ideas?

--
Lidia

damon shelton

unread,
Mar 24, 2016, 1:42:57 AM3/24/16
to python_in...@googlegroups.com
I would suggest looking into using the listHistory command to get back the history nodes of type anim curve 
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAB1%3D8yTd7L-fxAUmMoOGUcYBzVBpTZxo%2B1FX0LeLM%3DXtte_7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mark Jackson

unread,
Mar 24, 2016, 5:10:31 AM3/24/16
to python_inside_maya
Ah the fun of animLayers!!!!

Take a look in the Red9 API, I did a load of wrapping to get round this issue in the Red9_CoreUtils.FilterNode class. Basically the easiest way to get the data back is not going through the animLayers commands as they're basically all Gash, instead go through the history..


animCurves = [curve for curve in cmds.listHistory(nodes, pdo=True, lf=False, lv=treeDepth) if cmds.nodeType(curve, i=True)[0] == 'animCurve']

In the main filter code I change the treeDepth depending on if animLayers are present or not, I also do some post processing on the return to determine if the connected curve is ''safe'' to edit, ie not part of setDriven network or clip inputs etc

hope that helps

Mark


For more options, visit https://groups.google.com/d/optout.



--
-------------------------------------
Mark Jackson
CEO / Technical Director
red9consultancy.com

AK Eric

unread,
Mar 25, 2016, 3:34:15 PM3/25/16
to Python Programming for Autodesk Maya
I've done something similar that has worked well:

curves = mc.ls(mc.listHistory(myNodes), type = 'animCurve')
Reply all
Reply to author
Forward
0 new messages