This looks mighty suspicious. previous_rotation_values = itertools.izip(*channel_values1) try: previous_rotations = previous_rotation_values.next() except StopIteration: return False
I suspect this is creating a new iterator per iteration, returning the first value each time. The prior calls are also suspicious. control_iterator = NodesAnimationIterator([node_name]) channels1 = control_iterator.iterate_animated_channels('rotate') channel_values1 = list( channel.iter_values(frame_range) for channel in channels1 ) As a reader, I would have expected control_iterator to be an iterator, such that I could say: for control in control_iterator: # Do something with `control` But instead, it is.. 1. Creating what seems like a second iterator, channels1 2. *Unrolling* this iterator into channel_values1 3. Only to un-unroll the values into previous_rotation_values Not to mention this then happens again, over and over in a loop, shortly afterwards. If I was you, I would take a step back, rethink my strategy. :) Also, figure out which line is taking the longest; I suspect those unrolling of iterators. On Tue, 17 Dec 2019 at 01:26, kiteh <kiteh.0...@gmail.com> wrote: > Hi all, I am trying to write a script that checks for flipped curves > within a rig. > Initially I had one written up, though the script execution is very fast, > it is unable to process for any controllers that are either constrained or > if it is on animation layers. > > However, I have re-written my old script and currently while it is able to > iterate values on constrained/ animation layers, the execution now becomes > very slow as a result. > > In my scene, I have a human rig that comprises of approximately 300 > controllers, and most of its main controllers (eg. spine, chest etc) are > animated with a run cycle (81 frames). > When I selected all the controllers and run using the `old_code`, it took > less than a second or at most 2 seconds. As soon as I tried to run it with > the `new_code`, it took about 10 times longer, between 15- 19 seconds at > times. > > I am kind of stumped on how to efficiently speed up my `new_code` as the > slowness seems to be occurring at the `has_flip()` method. > Additionally, I also noted that, while running the `new_code`, script > editor is spewing the cycleCheck warning. (I do not think these cycleCheck > warning attributes to the time taken?) > > For your reference, here is my old and new code: > old_code <https://pastebin.com/mLfE0NeE> (unable to work on values on > constrained/ animation layer) > new_code <https://pastebin.com/SWfdSNpk> > > Appreciate in advance if anyone could kindly share with me any insights > that you have, or other methods that I could try out with. > > P.S: I apologize in advance for not able to provide a scene file as I am > unable to share the rig. > > -- > 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/1814c58b-5136-4b20-bcbc-e15b3ca4a412%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/1814c58b-5136-4b20-bcbc-e15b3ca4a412%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAFRtmOA9656m9ms_0r1wYhu3dCa4jpWPxkzWCwY0ffmu%3D3G0_w%40mail.gmail.com.