I added that in as a precaution to ensure that every frame animation is 
being "baked".
Let me try without that then

On Thursday, July 19, 2018 at 2:51:27 PM UTC-7, Justin Israel wrote:
>
> Is the cmds.currentTime(frame) necessary, if you are already passing a 
> "time" value to setKeyframe()? I imagine you are wasting a bunch of cpu 
> time changing the current frame in the scene and triggering updates. 
>
> On Fri, Jul 20, 2018 at 9:40 AM yann19 <yang...@gmail.com <javascript:>> 
> wrote:
>
>> Hi, I am writing up a script that works in a similar fashion as quick 
>> bake, select controllers from rigA and have the animation within to be 
>> transferred over to rigB.
>>
>> Currently the following code portion is taking quite some time, iterating 
>> through the frame range. Wondering if there are any other ways in which I 
>> can speed it up?
>>
>> def _bake(selection, frame_range):
>>     start_time = cmds.timerX()
>>
>>     # selection = controllers selected
>>     cmds.select(selection)
>>
>>     # Isolate to get the bake faster
>>     panelFocus = cmds.getPanel(withFocus=True)
>>     visPanels = cmds.getPanel(visiblePanels=True)
>>     modelPanels = cmds.getPanel(type="modelPanel")
>>     if modelPanels:
>>         for pan in modelPanels:
>>             finder = pan in visPanels
>>             if finder:
>>                 activePanel = pan
>>         cmds.setFocus(activePanel)
>>         cmds.scriptedPanel(
>>             "referenceEditorPanel1",
>>             edit=True,
>>             replacePanel=activePanel
>>         )
>>     total01 = cmds.timerX(startTime=start_time) # Took about 0.02
>>
>>     # Mostly looking at only Translate and Rotate channels.
>>     channels = ["translate", "rotate"]
>>     axis = ["X", "Y", "Z"]
>>     for frame in range(frame_range[0], frame_range[1]):
>>         cmds.currentTime(frame)
>>         for channel in channels:
>>             for axi in axis:
>>                 temp_attr = "".join((channel, axi))
>>                 cmds.setKeyframe(attribute=temp_attr, time=frame)
>>
>>     total02 = cmds.timerX(startTime=start_time) # Took about 27.66
>>
>>     # Back to the prespective
>>     cmds.modelPanel(
>>         activePanel,
>>         edit=True,
>>         replacePanel="referenceEditorPanel1"
>>     )
>>     cmds.setFocus(panelFocus)
>>
>>     # Filter baked curve
>>     cmds.filterCurve(filter="euler")
>>
>>     totalTime = cmds.timerX(startTime=start_time) # Took 28.11
>>
>>
>> -- 
>> 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 <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/9399f1ee-04fd-498d-8c95-cb952abdab53%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/9399f1ee-04fd-498d-8c95-cb952abdab53%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/55133529-7162-4bff-b16a-e93e53e56d60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to