Accessing attribute values from each frame in an animation

38 views
Skip to first unread message

unnikris...@gmail.com

unread,
Dec 21, 2018, 1:33:24 PM12/21/18
to Python Programming for Autodesk Maya
I have an animation that’s being generated in Maya. This animation cause attributes under a node to change over time. I want to access the attributes (about 200 of them) for each frame and write that into a file. I’m currently using the OpenMaya MFnDependencyNode to find the required node and then using dependencyNode.findPlug on each frame to access the values.

This works but its very slow and I was wondering if there’s a better way to go through the timeline and fetch attributes. Currently, for a 10 second animation (60 fps), it takes about 18 seconds to access this data. Is there a faster way to do this? Thanks.

mjlefevre

unread,
Dec 21, 2018, 2:25:55 PM12/21/18
to Python Programming for Autodesk Maya
Do these attributes have keyframes?
If so, access the curve data via MFnAnimCurve (I think?).

Failing that, using getAttr would surely be faster.

Justin Israel

unread,
Dec 21, 2018, 3:15:33 PM12/21/18
to python_in...@googlegroups.com


On Sat, Dec 22, 2018, 7:33 AM <unnikris...@gmail.com> wrote:
I have an animation that’s being generated in Maya. This animation cause attributes under a node to change over time. I want to access the attributes (about 200 of them) for each frame and write that into a file. I’m currently using the OpenMaya MFnDependencyNode to find the required node and then using dependencyNode.findPlug on each frame to access the values.

This works but its very slow and I was wondering if there’s a better way to go through the timeline and fetch attributes. Currently, for a 10 second animation (60 fps), it takes about 18 seconds to access this data. Is there a faster way to do this? Thanks.

Are you advancing the timeline frame by frame and getting a new plug each time? Have you tried just getting the plug once and then passing an MDGContext(MTime(...)) with the next frame as MTime to get all the values across time? That should be what getattr(time=...) does under the hood. Should be way cheaper than advancing the scene and getting a new plug each time. 


--
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/18ff8520-27a1-47a8-9b5f-3d2bf2d04744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

unnikris...@gmail.com

unread,
Dec 21, 2018, 5:15:45 PM12/21/18
to Python Programming for Autodesk Maya
I' not aware of MDGContext(). Let me take a look at what the api looks like. Do you mean something along these lines:

MTime t( 10. );
MDGContext ctx( t );
plug.getValue( oInput, ctx );

Justin Israel

unread,
Dec 21, 2018, 5:36:15 PM12/21/18
to python_in...@googlegroups.com
Yes
 

--
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.
Reply all
Reply to author
Forward
0 new messages