bakeresults in Python is super slow

1,158 views
Skip to first unread message

Jeremie Passerin

unread,
Dec 23, 2016, 5:56:23 PM12/23/16
to python_in...@googlegroups.com
Hello Maya coders !

I'm having a weird issue right now using the bakeresults command in Maya 2016.5 (aka ext2)
I've built a test scene with 500 locators constrained to 500 others that have a simple animation on 400 frames (Parent Constraint)

When I bake the animation to fcurve using the MEL
It's done in a about 40s
When I do it in Python it takes almost 5 minutes
I had to set simulation to False in Python otherwise... it's taking even longer... I wasn't able to get it to finish (I left it running for 2 hours)

Any idea ? any tips on baking a bunch of controllers that are constrained to something ? 

MEL
timer -s;
bakeResults -simulation true -t "1:400" -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -removeBakedAttributeFromLayer false -removeBakedAnimFromLayer false -bakeOnOverrideLayer false -minimizeRotation true {"slave", [...], "slave500"};
timer -e;
// Result: 25.241 // 

Python
from datetime import datetime as dt
import maya.cmds as cmds
start = dt.now()
cmds.bakeResults("slave", [...], ["slave500"], simulation=False,t=(0,400),sampleBy=1,disableImplicitControl=True,preserveOutsideKeys=True,sparseAnimCurveBake=False,removeBakedAttributeFromLayer=False,removeBakedAnimFromLayer=False,bakeOnOverrideLayer=False,minimizeRotation=True)
print dt.now() - start
>>> 0:04:44.691000


Thanks, 
Jeremie


Christopher Crouzet

unread,
Dec 24, 2016, 9:10:40 AM12/24/16
to python_in...@googlegroups.com
Hey Gerem!

I have no idea of what might be causing this slowdown with the Python version but I was curious to see how a quick and dirty custom implementation using the Maya API would fare, so I gave it a go. Here's the file: https://gist.github.com/christophercrouzet/e4daa884d4d4e08bce24addfe820af4d

It is a very naive implementation and it is the first time that I'm using the `OpenMaya.MDGContext` object, so chances are high that the code isn't optimal and could be speeded up. Also I didn't test it at all outside of the scene that it generates, so it might be crippled with bugs. And in all fairness it doesn't implement all the features covered by the `bakeResults` command, but still, it can be a starting point so give it a go to see if it helps. On my old laptop it takes 25 seconds to bake the animation on 6 attributes (pos + rot) for 500 locators over 400 frames. Maybe it'll be faster on your workstation?

On a side note I'm currently working on a small library to help benchmarking code for Maya, maybe that'll interest someone around here?


--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAKq4km-qgWqQZpVMa9biYMuTTvSh8GiKdfM7y1xmNYZ%2BeivpKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

Jeremie Passerin

unread,
Dec 24, 2016, 9:42:35 AM12/24/16
to python_in...@googlegroups.com
Thanks Christopher, 
I'll take a look that could be useful.

I found what was the problem with my scene. It was the parallel evaluation turned on. 
I turned it off and things seem to work much better. I also suspended the refreshing of the viewport, now I have some decent result.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--

--
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+unsub...@googlegroups.com.

Robert White

unread,
Dec 25, 2016, 12:54:39 AM12/25/16
to Python Programming for Autodesk Maya
Also, preserveOutsideKeys used to cause some major slowdown in 2014/2015. I believe the bug was finally fixed in 2016, so that might be another culprit.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAKq4km-qgWqQZpVMa9biYMuTTvSh8GiKdfM7y1xmNYZ%2BeivpKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

yury nedelin

unread,
Dec 26, 2016, 12:01:17 AM12/26/16
to python_in...@googlegroups.com
Consider not using that command at all, unless you need all of it full functionality. If you simply need the per frame position and rotation just query it with something like xform() or get() and store it in data for further use.  This function is handy but have always been slow and when I was using for large bakes, few versions ago, it would kill memory if numbers were high. Did you notice that it actually finishes the bake and just stalls Maya for a while after that , it used to do that. Very annoying. 
Yury



To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--

--
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+unsubscribe@googlegroups.com.

--
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+unsub...@googlegroups.com.

Alok Gandhi

unread,
Dec 26, 2016, 12:43:08 AM12/26/16
to python_in...@googlegroups.com
And then there is atom
Reply all
Reply to author
Forward
0 new messages