本文整理汇总了Python中maya.cmds.timeControl函数的典型用法代码示例。如果您正苦于以下问题:Python timeControl函数的具体用法?Python timeControl怎么用?Python timeControl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeControl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getStartAndEnd
def _getStartAndEnd():
gPlayBackSlider = mm.eval('$temp=$gPlayBackSlider')
if mc.timeControl(gPlayBackSlider, query=True, rangeVisible=True):
start, end = mc.timeControl(gPlayBackSlider, query=True, rangeArray=True)
return start, end-1
return None, None
示例2: plot
def plot():
curves = mc.keyframe(q=1, sl=1, name=1)
if type(curves).__name__ != 'NoneType':
for curve in curves:
indexes = mc.keyframe(curve, q=1, sl=1, iv=1)
if len(indexes) != 1:
startTime = int(mc.keyframe(curve, q=1, tc=1, index=tuple([indexes[0]]))[0])
endTime = int(mc.keyframe(curve, q=1, tc=1, index=tuple([indexes[1]]))[0])
mc.selectKey(cl=1)
for point in range(startTime, endTime):
mc.setKeyframe(curve, insert=1, time=point)
mc.selectKey(curve, time=( (startTime+0.01), (endTime-0.01) ), add=1, k=1)
else:
mc.warning('Only one keyframe is selected for the curve ' + curve + '.')
else:
sels = mc.ls(sl=1)
if sels:
timeSlider = mm.eval('$tmp = $gPlayBackSlider')
if mc.timeControl(timeSlider, q=1, rv=1) == 1:
startTime = int(mc.timeControl(timeSlider, q=1, ra=1)[0])
endTime = int(mc.timeControl(timeSlider, q=1, ra=1)[1])
else:
startTime = int(mc.playbackOptions(q=1, min=1))
endTime = int(mc.playbackOptions(q=1, max=1))
curves = mc.keyframe(q=1, name=1)
for curve in curves:
for point in range(startTime, endTime):
mc.setKeyframe(curve, insert=1, time=point)
mc.selectKey(curve, time=( (startTime+0.01), (endTime-0.01) ), add=1, k=1)
else:
mc.warning('Nothing is selected.')
示例3: 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
示例4: setActive
def setActive(self):
'''
Set sound node as active on the timeSlider
'''
if self.isLoaded:
gPlayBackSlider = mel.eval("string $temp=$gPlayBackSlider")
cmds.timeControl(gPlayBackSlider, e=True, ds=1, sound=self.audioNode)
示例5: doPlayblast
def doPlayblast(self, camera):
G.TU_movie = None
G.TU_audioFile = None
G.TU_audioOffsetSec = None
winName = 'playblastWindow'
overscan = cmds.getAttr("%s.overscan"%camera)
audioTrack = cmds.timeControl(G.playBackSliderPython, query=True, sound=True)
rangeVisible = cmds.timeControl(G.playBackSliderPython, query=True, rangeVisible=True )
widthHeight = utilMod.getRenderResolution()
if cmds.window(winName, query=True, exists=True): cmds.deleteUI(winName)
window = cmds.window(winName, widthHeight=widthHeight)
form = cmds.formLayout()
editor = cmds.modelEditor()
column = cmds.columnLayout('true')
cmds.formLayout( form, edit=True, attachForm=[(column, 'top', 0), (column, 'left', 0), (editor, 'top', 0), (editor, 'bottom', 0), (editor, 'right', 0)], attachNone=[(column, 'bottom'), (column, 'right')], attachControl=(editor, 'left', 0, column))
cmds.modelEditor(editor, edit=True, camera=camera, activeView=True)
cmds.showWindow( window )
cmds.window( winName, edit=True, topLeftCorner=(0, 0), widthHeight=[200,200])
utilMod.cameraViewMode(editor)
cmds.setAttr("%s.overscan"%camera, 1)
if rangeVisible:
range = animMod.getTimelineRange(float=False)
rFrom = range[0]
rTo = range[1]-1
else:
rFrom = cmds.playbackOptions(query=True, minTime=True)
rTo = cmds.playbackOptions(query=True, maxTime=True)
if G.currentStudio == None:
G.TU_movie = cmds.playblast(format="qt", sound=audioTrack, startTime=rFrom ,endTime=rTo , viewer=1, showOrnaments=0, offScreen=True, fp=4, percent=50, compression="png", quality=70, widthHeight=widthHeight, clearCache=True)
else:
fps = mel.eval("currentTimeUnitToFPS")
if audioTrack:
G.TU_audioFile = cmds.sound(audioTrack, query=True, file=True)
audioOffset = cmds.sound(audioTrack, query=True, offset=True)
G.TU_audioOffsetSec = str((rFrom - audioOffset)/-fps)
movieName = cmds.playblast(format="image", startTime=rFrom ,endTime=rTo , viewer=0, showOrnaments=0, offScreen=True, fp=4, percent=50, compression="jpg", quality=70, widthHeight=widthHeight, clearCache=True)
if movieName:
G.TU_movie = "%s.%s-%s#.jpg"%(movieName.split(".")[0], int(rFrom), int(rTo))
if audioTrack: G.TU_audioOffsetSec = audioOffset
self.playMovie(G.TU_movie, G.TU_audioFile, G.TU_audioOffsetSec)
if cmds.window(winName, query=True, exists=True): cmds.deleteUI(winName)
cmds.setAttr("%s.overscan"%camera, overscan)
if not G.TU_movie: return
save = aToolsMod.getUserPref("saveAfterPlayblasting", default=True)
if save and not rangeVisible: cmds.file(save=True)
示例6: 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
示例7: getPlaybackRange
def getPlaybackRange():
'''
returns a 2-tuple of startTime, endTime. The values are taken from the visible playback unless there is a time selection.
If there is a time selection, then its range is returned instead
'''
if cmd.timeControl( 'timeControl1', q=True, rv=True ): #NOTE: timeControl1 is the name of maya's default, global timeControl widget...
return cmd.timeControl( 'timeControl1', q=True, range=True )
return int( cmd.playbackOptions( q=True, min=True ) ), int( cmd.playbackOptions( q=True, max=True ) )
示例8: _getStartAndEnd
def _getStartAndEnd():
'''
Only return start and end if frame range is highlighted. Otherwise use all available animation.
'''
gPlayBackSlider = mm.eval('$temp=$gPlayBackSlider')
if mc.timeControl(gPlayBackSlider, query=True, rangeVisible=True):
start, end = mc.timeControl(gPlayBackSlider, query=True, rangeArray=True)
return start, end-1
return None, None
示例9: pin_control
def pin_control():
# Rigging Dojo: 2016 v.2
aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
selection = cmds.ls(sl=True)
selectionActive = cmds.timeControl(aPlayBackSliderPython, query=True, rangeVisible=True)
selectedRange = cmds.timeControl(aPlayBackSliderPython, query=True, rangeArray=True)
frameRange = range(*map(int, selectedRange))
zeroStartKey = cmds.setKeyframe(selection, time=(selectedRange[0] - 1), id=True) # zero the frames to base layer adjust as needed
startTime = cmds.currentTime(selectedRange[0]) # makesure pose is from the start of the selection
keyRange = cmds.setKeyframe(selection, time=frameRange) # Set all the keys at the same time
zeroEndKey = cmds.setKeyframe(selection, time=(selectedRange[1] + 1), id=True) # zero the frames to base layer adjust as needed
示例10: storeSettings
def storeSettings(self):
'''
main work function, store all UI settings
'''
self.dataStore['autoKey'] = cmds.autoKeyframe(query=True, state=True)
# timeline management
self.dataStore['currentTime'] = cmds.currentTime(q=True)
self.dataStore['minTime'] = cmds.playbackOptions(q=True, min=True)
self.dataStore['maxTime'] = cmds.playbackOptions(q=True, max=True)
self.dataStore['startTime'] = cmds.playbackOptions(q=True, ast=True)
self.dataStore['endTime'] = cmds.playbackOptions(q=True, aet=True)
self.dataStore['playSpeed'] = cmds.playbackOptions(query=True, playbackSpeed=True)
self.dataStore['playLoop'] = cmds.playbackOptions(query=True, loop=True)
# unit management
self.dataStore['timeUnit'] = cmds.currentUnit(q=True, fullName=True, time=True)
self.dataStore['sceneUnits'] = cmds.currentUnit(q=True, fullName=True, linear=True)
self.dataStore['upAxis'] = cmds.upAxis(q=True, axis=True)
# viewport colors
self.dataStore['displayGradient'] = cmds.displayPref(q=True, displayGradient=True)
# objects colors
self.dataStore['curvecolor'] = cmds.displayColor("curve", q=True, dormant=True)
# panel management
self.dataStore['panelStore'] = {}
for panel in ['modelPanel1', 'modelPanel2', 'modelPanel3', 'modelPanel4']:
if not cmds.modelPanel(panel, q=True, exists=True):
continue
self.dataStore['panelStore'][panel] = {}
self.dataStore['panelStore'][panel]['settings'] = cmds.modelEditor(panel, q=True, sts=True)
activeCam = cmds.modelPanel(panel, q=True, camera=True)
if not cmds.nodeType(activeCam) == 'camera':
activeCam = cmds.listRelatives(activeCam, f=True)[0]
self.dataStore['panelStore'][panel]['activeCam'] = activeCam
# camera management
# TODO : store the camera field of view etc also
self.dataStore['cameraTransforms'] = {}
for cam in ['persp', 'top', 'side', 'front']:
try:
self.dataStore['cameraTransforms'][cam] = [cmds.getAttr('%s.translate' % cam),
cmds.getAttr('%s.rotate' % cam),
cmds.getAttr('%s.scale' % cam)]
except:
log.debug("Camera doesn't exists : %s" % cam)
# sound management
self.dataStore['activeSound'] = cmds.timeControl(self.gPlayBackSlider, q=True, s=1)
self.dataStore['displaySound'] = cmds.timeControl(self.gPlayBackSlider, q=True, ds=1)
示例11: _getTime
def _getTime(type):
timeSlider = mm.eval('$tmp = $gPlayBackSlider')
if type == 'playbackMin':
return mc.playbackOptions(q=1, min=1)
elif type == 'playbackMax':
return mc.playbackOptions(q=1, max=1)
elif type == 'rangeSelected':
return mc.timeControl(timeSlider, q=1, rv=1)
elif type == 'rangeMin':
return mc.timeControl(timeSlider, q=1, ra=1)[0]
elif type == 'rangeMax':
return mc.timeControl(timeSlider, q=1, ra=1)[1]
示例12: scrubbingUndo
def scrubbingUndo(onOff):
G.playBackSliderPython = G.playBackSliderPython or mel.eval('$aTools_playBackSliderPython=$gPlayBackSlider')
pc = "from maya import cmds;"
rc = "from maya import cmds;"
if not onOff:
pc += "cmds.undoInfo(stateWithoutFlush=False); "
rc += "cmds.undoInfo(stateWithoutFlush=True); "
pc += "cmds.timeControl('%s',edit=True,beginScrub=True)"%G.playBackSliderPython
rc += "cmds.timeControl('%s',edit=True,endScrub=True)"%G.playBackSliderPython
cmds.timeControl( G.playBackSliderPython, edit=True, pressCommand=pc, releaseCommand=rc)
示例13: openFile
def openFile():
"""
Function to open a new wav file into the scene.
Creates a new Maya sound node and changes the timeslider to use the audio for playback while scrubbing.
Prepares the wav file for reading audio data.
Adjusts the UI to display the current audio parameters and progress bar for the new track.
"""
global wavFile, params, frames
#open file dialog
fileNameList = cmds.fileDialog2(cap="Choose Audio File...", ff="*.wav", fm=4, ds=2, okc="Open")
#convert result from dialog box to a useable string
fileName = str(fileNameList[0])
#load the file name into the info text area in the UI
cmds.text('currentAudioPath', edit=True, label="Currently Loaded: "+fileName)
#delete any existing audio nodes
if(cmds.objExists('audio')):
cmds.select('audio')
cmds.delete()
#create a new sound node
cmds.sound(f=fileName, n="audio")
#set the 'audio' node to be the audio for the timeline.
#--------- code from documentation starts here ------------#
gPlayBackSlider = mel.eval( '$tmpVar=$gPlayBackSlider' )
cmds.timeControl( gPlayBackSlider, edit=True, sound='audio', displaySound=True)
#--------- code from documentation ends here -------------#
#set the playback range to the range of the audio
cmds.playbackOptions(min=0, aet=(cmds.getAttr('audio.duration')), max=(cmds.getAttr('audio.duration')))
#------- set up the stream -------#
wavFile = wave.open(fileName)
params = wavFile.getparams()
frames = wavFile.readframes(params[3])
#update the info text with the audio parameters.
cmds.text('currentParams', edit=True, label=str(params))
#set the max of the progress bar to the number of audio frames in the selected track
cmds.progressBar('progress', edit=True, maxValue = params[3])
print "Result: ",fileName, "has been loaded."
示例14: updateFrameRange
def updateFrameRange(self, all=False):
rangeVisible = cmds.timeControl(G.playBackSliderPython, query=True, rangeVisible=True )
if not rangeVisible or all:
range = [cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True)+1]
else:
range = cmds.timeControl(G.playBackSliderPython, query=True, rangeArray=True)
#range[1] -= 1
self.firstFrame = range[0]
self.lastFrame = range[1]-1
self.updateSortedRange()
self.updateCameraMatrices()
示例15: parse_active_scene
def parse_active_scene():
"""Parse active scene for arguments for capture()
*Resolution taken from render settings.
"""
time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")
return {
"start_frame": cmds.playbackOptions(minTime=True, query=True),
"end_frame": cmds.playbackOptions(maxTime=True, query=True),
"width": cmds.getAttr("defaultResolution.width"),
"height": cmds.getAttr("defaultResolution.height"),
"compression": cmds.optionVar(query="playblastCompression"),
"filename": (cmds.optionVar(query="playblastFile")
if cmds.optionVar(query="playblastSaveToFile") else None),
"format": cmds.optionVar(query="playblastFormat"),
"off_screen": (True if cmds.optionVar(query="playblastOffscreen")
else False),
"show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
else False),
"quality": cmds.optionVar(query="playblastQuality"),
"sound": cmds.timeControl(time_control, q=True, sound=True) or None
}