本文整理汇总了Python中maya.cmds.autoKeyframe函数的典型用法代码示例。如果您正苦于以下问题:Python autoKeyframe函数的具体用法?Python autoKeyframe怎么用?Python autoKeyframe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了autoKeyframe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load():
'''loads animation environment'''
print "loading animation environment presets..."
#set autoKey
cmds.autoKeyframe( state=True )
#set 24fps and playback on all viewports
cmds.playbackOptions(ps=1.0, v='all')
#set unlimited undo's
cmds.undoInfo( state=True, infinity=True )
#set manipulator sizes
if lib.checkAboveVersion(2014):
cmds.manipOptions( r=False, hs=55, ls=4, sph=1 )
else:
cmds.manipOptions( r=False, hs=55, ls=4 )
#set framerate visibility
mel.eval("setFrameRateVisibility(1);")
#gimbal rotation
cmds.manipRotateContext('Rotate', e=True, mode=2)
#world translation
cmds.manipMoveContext('Move', e=True, mode=2)
#time slider height
aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
cmds.timeControl(aPlayBackSliderPython, h=45, e=True);
#special tick color
cmds.displayRGBColor("timeSliderTickDrawSpecial", 1,0.5,0)
#check if hotkeys have been set
if (cmds.hotkey( 't', ctl=True, query=True, name = True)== 'CharacterAnimationEditorNameCommand'):
print "Hotkeys have been previously loaded"
else:
setHotkeys('default')
print "ENVIRONMENT SET\n", #the comma forces output on the status line
示例2: store
def store(self):
'''
store animation
'''
# make sure o
if self.poseOnly:
self.mtrx.append(cmds.xform(self.obj, q=True, m=True, ws=True))
else:
if self.keys:
current = cmds.currentTime(q=True)
# ui off
cn.uiEnable(controls='modelPanel')
# autokey state
autoK = cmds.autoKeyframe(q=True, state=True)
cmds.autoKeyframe(state=False)
for key in self.keys:
cmds.currentTime(key)
self.pos.append(cmds.xform(self.obj, q=True, rp=True, ws=True))
self.rot.append(cmds.xform(self.obj, q=True, ro=True, ws=True))
self.mtrx.append(cmds.xform(self.obj, q=True, m=True, ws=True))
# restore everything
cmds.currentTime(current)
cmds.autoKeyframe(state=autoK)
cn.uiEnable(controls='modelPanel')
else:
message('No keys, forcing timeline range.', maya=True)
self.keys = range(int(self.rng.start), int(self.rng.end))
self.rng.keyStart = self.rng.start
self.rng.keyEnd = self.rng.end
self.store()
示例3: changeRO
def changeRO(obj, ro):
'''
'''
roLst = ['xyz', 'yzx', 'zxy', 'xzy', 'yxz', 'zyx']
if cmds.getAttr(obj + '.rotateOrder', settable=1):
keyframes = getKeyedFrames(obj)
origRO = cmds.getAttr(obj + '.rotateOrder')
if ro != roLst[origRO]:
if keyframes:
cn.uiEnable(controls='modelPanel')
r = getRange()
autoK = cmds.autoKeyframe(q=True, state=True)
cmds.autoKeyframe(state=False)
i = r[0]
current = r[2]
cmds.currentTime(i)
cmds.currentTime(cmds.findKeyframe(which='previous'))
cmds.xform(obj, roo=ro)
for key in keyframes:
cmds.currentTime(key)
cmds.setAttr(obj + '.rotateOrder', origRO)
cmds.xform(obj, roo=ro)
cmds.setKeyframe(obj + '.rotate')
cmds.currentTime(current)
cmds.autoKeyframe(state=autoK)
cn.eulerFilter(obj, tangentFix=True)
cn.uiEnable(controls='modelPanel')
else:
cmds.xform(obj, roo=ro)
# done
message('Rotate order changed: -- ' + roLst[origRO] + ' to ' + ro, maya=True)
else:
message('Rotate order already set -- ' + ro)
else:
message('FAIL. Rotate order is LOCKED or CONNECTED to a custom attribute.', maya=True)
示例4: func
def func( *args, **kwargs ):
initialState = cmd.autoKeyframe( q=True, state=True )
cmd.autoKeyframe( state=False )
try:
return f( *args, **kwargs )
finally:
cmd.autoKeyframe( state=initialState )
示例5: __exit__
def __exit__(self, *exc_info):
cmds.autoKeyframe(state=self.autoKeyState)
cmds.currentTime(self.time)
if self.selection:
cmds.select(self.selection)
示例6: putObjects
def putObjects(self, atCurrentFrame=False):
# print self.sel
# print self.putObjectList
autoKey = cmds.autoKeyframe(q=True, state=True)
cmds.autoKeyframe(state=False)
# current #NO LONGER USED, REMOVE ONCE MERGED WITH WORK COPY OF KET
# CLASS
if atCurrentFrame:
current = cmds.currentTime(q=True)
if self.start > current:
self.offset = current - self.start
else:
self.offset = ((self.start - current) * -1.0) + 0.0
# print self.offset
# put
num = len(self.objects)
i = 1
uiEnable()
for obj in self.objects:
if cmds.objExists(obj.name):
message(str(i) + ' of ' + str(num) + ' -- ' + obj.name, maya=True)
cmds.refresh(f=1)
obj.offset = self.offset
obj.putAttribute()
else:
cmds.warning(
'Object ' + obj.name + ' does not exist, skipping.')
i = i + 1
uiEnable()
cmds.autoKeyframe(state=autoKey)
示例7: distributeKeys
def distributeKeys(step=3.0, destructive=True, forceWholeFrames=True):
'''
operates on selected curves
'''
s = GraphSelection()
sel = cmds.ls(sl=1, fl=True)
rng = fr.Get()
if s.crvs:
# gather info
autoK = cmds.autoKeyframe(q=True, state=True)
frames = getKeyedFrames(s.crvs)
# process start/end of loop
framesNew = []
if rng.selection:
for f in frames:
if f >= rng.keyStart and f <= rng.keyEnd:
framesNew.append(f)
frames = framesNew
#
cut = []
# print frames
if forceWholeFrames:
framesOrig = frames
frames = [round(frame) for frame in frames]
framesPartial = list(set(framesOrig) - set(frames))
cut = [frame for frame in framesPartial]
# print cut, '______cut'
lastFrame = frames[len(frames) - 1]
count = frames[0]
i = frames[0]
# turn off autokey
cmds.autoKeyframe(state=False)
framesNew = []
# process keys
while i < lastFrame:
if i == count:
cmds.setKeyframe(s.crvs, i=True, t=count)
framesNew.append(count)
count = count + step
else:
if i in frames:
cut.append(i)
i = i + 1
# remove keys is destructive
if destructive:
framesDel = sorted(list(set(frames) - set(framesNew)))
for frame in framesDel:
cut.append(frame)
# print framesOrig, '________orig'
# print framesNew, '________new'
# print cut, '_________cut'
if cut:
for frame in cut:
if frame >= rng.keyStart and frame <= rng.keyEnd:
cmds.cutKey(sel, clear=1, time=(frame, frame))
# restore autokey
cmds.autoKeyframe(state=autoK)
else:
message('Select one or more anima curves', maya=1)
示例8: restoreSettings
def restoreSettings(self):
'''
restore all UI settings
'''
cmds.autoKeyframe(state=self.dataStore['autoKey'])
# timeline management
cmds.currentTime(self.dataStore['currentTime'])
cmds.playbackOptions(min=self.dataStore['minTime'])
cmds.playbackOptions(max=self.dataStore['maxTime'])
cmds.playbackOptions(ast=self.dataStore['startTime'])
cmds.playbackOptions(aet=self.dataStore['endTime'])
cmds.playbackOptions(ps=self.dataStore['playSpeed'])
cmds.playbackOptions(loop=self.dataStore['playLoop'])
# unit management
cmds.currentUnit(time=self.dataStore['timeUnit'])
cmds.currentUnit(linear=self.dataStore['sceneUnits'])
if not cmds.upAxis(axis=True, q=True) == self.dataStore['upAxis']:
cmds.upAxis(axis=self.dataStore['upAxis'])
log.debug('Restored PlayBack / Timeline setup')
# viewport colors
cmds.displayPref(displayGradient=self.dataStore['displayGradient'])
cmds.displayRGBColor(resetToSaved=True)
# objects colors
cmds.displayColor("curve", self.dataStore['curvecolor'], dormant=True)
# panel management
for panel, data in self.dataStore['panelStore'].items():
try:
cmdString = data['settings'].replace('$editorName', panel)
mel.eval(cmdString)
log.debug("Restored Panel Settings Data >> %s" % panel)
mel.eval('lookThroughModelPanel("%s","%s")' % (data['activeCam'], panel))
log.debug("Restored Panel Active Camera Data >> %s >> cam : %s" % (panel, data['activeCam']))
except:
log.debug("Failed to fully Restore ActiveCamera Data >> %s >> cam : %s" % (panel, data['activeCam']))
# camera management
for cam, settings in self.dataStore['cameraTransforms'].items():
try:
cmds.setAttr('%s.translate' % cam, settings[0][0][0], settings[0][0][1], settings[0][0][2])
cmds.setAttr('%s.rotate' % cam, settings[1][0][0], settings[1][0][1], settings[1][0][2])
cmds.setAttr('%s.scale' % cam, settings[2][0][0], settings[2][0][1], settings[2][0][2])
log.debug('Restored Default Camera Transform Data : % s' % cam)
except:
log.debug("Failed to fully Restore Default Camera Transform Data : % s" % cam)
# sound management
if self.dataStore['displaySound']:
cmds.timeControl(self.gPlayBackSlider, e=True, ds=1, sound=self.dataStore['activeSound'])
log.debug('Restored Audio setup')
else:
cmds.timeControl(self.gPlayBackSlider, e=True, ds=0)
log.debug('Scene Restored fully')
return True
示例9: __exit__
def __exit__(self, *args):
#reset settings
mc.cycleCheck(evaluation=self.resetCycleCheck)
mc.autoKeyframe(state=self.resetAutoKey)
if self.sel:
mc.select(self.sel)
self.isolate(False)
示例10: func
def func(*args, **kwargs):
initialState = cmd.autoKeyframe(q=True, state=True)
cmd.autoKeyframe(state=False)
try:
ret = f(*args, **kwargs)
except:
raise
finally:
cmd.autoKeyframe(state=initialState)
return ret
示例11: __exit__
def __exit__(self, exc_type, exc_value, traceback):
# Close the undo chunk, warn if any exceptions were caught:
cmds.autoKeyframe(state=self.autoKeyState)
cmds.currentTime(self.timeStore)
log.info('autoKeyState restored: %s' % self.autoKeyState)
log.info('currentTime restored: %f' % self.timeStore)
cmds.undoInfo(closeChunk=True)
if exc_type:
log.exception('%s : %s'%(exc_type, exc_value))
# If this was false, it would re-raise the exception when complete
return True
示例12: actualFunc
def actualFunc(*args):
start = time.clock()
initialAutoKeyState = cmd.autoKeyframe(q=True,state=True)
cmd.autoKeyframe(state=False)
api.mel.zooAllViews(0)
retVal = f(*args)
api.mel.zooAllViews(1)
cmd.autoKeyframe(state=initialAutoKeyState)
print 'time taken',time.clock()-start,'secs'
return retVal
示例13: __enter__
def __enter__(self):
self.sel = mc.ls(sl=True)
self.modelPanels = mc.getPanel(type='modelPanel')
self.isolate(True)
mc.select(clear=True)
#save and turn off settings that might print to the script editor
self.resetCycleCheck = mc.cycleCheck(query=True, evaluation=True)
mc.cycleCheck(evaluation=False)
self.resetAutoKey = mc.autoKeyframe(query=True, state=True)
mc.autoKeyframe(state=False)
示例14: distributeKeys
def distributeKeys(count=3.0, destructive=True):
sel = cmds.ls(sl=1, fl=True)
rng = fr.Get()
if sel:
# gather info
autoK = cmds.autoKeyframe(q=True, state=True)
frames = getKeyedFrames(sel)
if not frames:
# add a bake if no keys exist, then get keys again
message('No keys found, setting a key start/end of range.', maya=1)
cmds.setKeyframe(sel, t=(rng.start, rng.start))
cmds.setKeyframe(sel, t=(rng.end, rng.end))
frames = getKeyedFrames(sel)
# return None
# process start/end of loop
framesNew = []
if rng.selection:
for f in frames:
if f >= rng.keyStart and f <= rng.keyEnd:
framesNew.append(f)
frames = framesNew
#
print frames
lastFrame = frames[len(frames) - 1]
step = frames[0]
i = frames[0]
cut = []
# turn off autokey
cmds.autoKeyframe(state=False)
# process keys
while i < lastFrame:
if i == step:
cmds.setKeyframe(sel, i=True, t=step)
step = step + count
else:
if i in frames:
cut.append(i)
i = i + 1
# remove keys is destructive
if destructive:
# print cut, '_________'
if cut:
for frame in cut:
cmds.cutKey(sel, clear=1, time=(frame, frame))
# restore autokey
cmds.autoKeyframe(state=autoK)
else:
message('Select one or more objects', maya=1)
示例15: restoreSettings
def restoreSettings(self):
'''
restore all UI settings
'''
cmds.autoKeyframe(state=self.dataStore['autoKey'])
#timeline management
cmds.currentTime(self.dataStore['currentTime'])
cmds.playbackOptions(min=self.dataStore['minTime'])
cmds.playbackOptions(max=self.dataStore['maxTime'])
cmds.playbackOptions(ast=self.dataStore['startTime'])
cmds.playbackOptions(aet=self.dataStore['endTime'])
cmds.playbackOptions(ps=self.dataStore['playSpeed'])
#unit management
cmds.currentUnit(time=self.dataStore['timeUnit'])
cmds.currentUnit(linear=self.dataStore['sceneUnits'])
cmds.upAxis(axis=self.dataStore['upAxis'])
log.info('Restored PlayBack / Timeline setup')
#panel management
for panel, data in self.dataStore['panelStore'].items():
cmdString = data['settings'].replace('$editorName', panel)
mel.eval(cmdString)
log.info("Restored Panel Settings Data >> %s" % panel)
mel.eval('lookThroughModelPanel("%s","%s")' % (data['activeCam'], panel))
log.info("Restored Panel Active Camera Data >> %s >> cam : %s" % (panel, data['activeCam']))
# camera management
for cam, settings in self.dataStore['cameraTransforms'].items():
cmds.setAttr('%s.translate' % cam, settings[0][0][0], settings[0][0][1], settings[0][0][2])
cmds.setAttr('%s.rotate' % cam, settings[1][0][0], settings[1][0][1], settings[1][0][2])
cmds.setAttr('%s.scale' % cam, settings[2][0][0], settings[2][0][1], settings[2][0][2])
log.info('Restored Default Camera Transform Data : % s' % cam)
#sound management
if self.dataStore['displaySound']:
cmds.timeControl(self.gPlayBackSlider, e=True, ds=1, sound=self.dataStore['activeSound'])
log.info('Restored Audio setup')
else:
cmds.timeControl(self.gPlayBackSlider, e=True, ds=0)
return True