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 [email protected].
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.