Re: [Maya-Python] Speed up setting of keyframe

2018-07-30 Thread yann19
Thank you all for the replies, really appreciate it :D

Will try to find the bottleneck issue which seemingly is pointing towards 
`cmds.currentTime` for the current code that is and spending more time to 
find out what is the exact cause..

-- 
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/e5a0a6b6-18e1-44bb-91b3-e072fe443daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-25 Thread yann19
Hi combi,

Sorry for the late reply. I do not think the use of `cmds.refresh()` may 
have any effects here.
Rather, it is the `setting` of the currentTime that seemingly needs to be 
action so that the baking of keyframes are done properly.

-- 
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/2ee6fa25-1366-4c83-90bf-2772f4232167%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-21 Thread Nicolas Combecave
Maybe not applicabl;e to your problem, but we got some significant
improvements on some of our time-dependent tools using
cmds.refresh(suspend=True) at start of the process and
cmds.refresh(suspend=False) at the end.


If you happen to use this concept more and more, it can be usefull to make
a decorator out of it.


Le sam. 21 juil. 2018 à 01:57, yann19  a écrit :

> Perhaps it is something within my code that may needs to be refine.
> I tried to bake it per controller but it seems to take even longer...
>
> I have pasted my code here - https://pastebin.com/raw/25UhLt6C for
> reference.
>
> Appreciate if anyone could help to take a look and feedback :)
>
> --
> 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/01ff3672-50a2-414a-b0fe-65bb5074a4e3%40googlegroups.com
> 
> .
> 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/CAD65uq%3DHR9RQoESVGvvnpz5WJN_EA_Y8wuCQd4Ys6zwUPLc1rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-20 Thread yann19
Perhaps it is something within my code that may needs to be refine.
I tried to bake it per controller but it seems to take even longer...

I have pasted my code here - https://pastebin.com/raw/25UhLt6C for 
reference.

Appreciate if anyone could help to take a look and feedback :) 

-- 
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/01ff3672-50a2-414a-b0fe-65bb5074a4e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-19 Thread yann19
Only the first frame is being baked while the rest is static, though the 
process is fast, when using "update=False" or commenting that line out..

-- 
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/b817eeae-2728-4590-9c35-0636982b6c78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-19 Thread Justin Israel
On Fri, Jul 20, 2018 at 10:49 AM yann19  wrote:

> I added that command in, to ensure that animation is being baked properly
> in each frame across the frame range defined.
>
> I tried commenting out that particular line, only the first frame is being
> baked while the rest of the frames are static
>

Does it make a difference if you only change the current time once, after
all the keyframes are set? Or what about using currentTime(frame,
update=False) ?


>
>
> 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.
>>
> --
> 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/205c754e-2140-426c-943d-e15313be8105%40googlegroups.com
> 
> .
> 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/CAPGFgA1xbhDjwF5WFMi9xwjmOhUZ0OroLgmEDO0diHWPcMp9PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-19 Thread yann19
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 > 
> 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 .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/9399f1ee-04fd-498d-8c95-cb952abdab53%40googlegroups.com
>>  
>> 
>> .
>> 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.


Re: [Maya-Python] Speed up setting of keyframe

2018-07-19 Thread Justin Israel
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  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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/9399f1ee-04fd-498d-8c95-cb952abdab53%40googlegroups.com
> 
> .
> 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/CAPGFgA0ndEPWWLRth5asmm1ScwOtj-wEyMyqxBhXhrtm3N1Lfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.