本文整理汇总了Python中maya.cmds.playbackOptions函数的典型用法代码示例。如果您正苦于以下问题:Python playbackOptions函数的具体用法?Python playbackOptions怎么用?Python playbackOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了playbackOptions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setTimelineRange
def setTimelineRange(self, range=None, *args):
rangeVisible = cmds.timeControl( G.playBackSliderPython, query=True, rangeVisible=True )
if not rangeVisible and not range:
range = [cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True)+1]
if range or rangeVisible:
if not range: range = animMod.getTimelineRange(float=False)
rFrom = range[0]
rTo = range[1]-1
cmds.playbackOptions(minTime=rFrom, maxTime=rTo)
if self.getTimelineRanges() != None:
ranges = eval(self.getTimelineRanges())
else:
ranges = []
if not range in ranges:
ranges.append(range)
aToolsMod.saveInfoWithScene(STORE_NODE, RANGE_ATTR, ranges)
utilMod.deselectTimelineRange()
示例2: exportDeformAnimation
def exportDeformAnimation(folder):
'''Use MDD file to export defrom animation.'''
minframe = int( mc.playbackOptions(q = True, min = True) )
maxframe = int( mc.playbackOptions(q = True, max = True) )
totalframes = maxframe - minframe + 1
t = mc.currentUnit(q = True, t = True)
fps = _mfps[t]
parts = []
selectionList = mo.MSelectionList()
mo.MGlobal.getActiveSelectionList(selectionList)
itList = mo.MItSelectionList(selectionList, mo.MFn.kTransform)
while not itList.isDone():
path = mo.MDagPath()
itList.getDagPath(path)
partialName = str(path.partialPathName())
name = partialName.split(":")[-1]
part = MDD(name, mo.MFnMesh(path), totalframes, fps)
parts.append(part)
itList.next()
# add animation
for frame in range(minframe, maxframe + 1):
mc.currentTime(frame, edit = True)
for p in parts:
p.addFrame()
# write files
for p in parts:
p.writeToFile(folder)
print "write %s done." % p.name
print "All is done."
return True
示例3: go
def go():
try:
assetName, assetType, version = geo.decodeFileName()
except IndexError:
showErrorDialog()
return
if not assetType == 'animation':
showErrorDialog()
return
fileName = mc.file(q=True, sceneName=True)
dirName = os.path.dirname(fileName)
source = amu.getCheckinDest(dirName)
blastPath = os.path.join(os.path.dirname(source), 'playblasts')
versionNum = amu.getLatestVersion(source)+1
name = os.path.join(blastPath, assetName+"_v"+("%03d" % versionNum))
startFrame = mc.playbackOptions(q=True, min=True)
endFrame = mc.playbackOptions(q=True, max=True)
choice = mc.confirmDialog( title = 'Playblast Tool'
, message = 'What kind of playblast?'
, button = ['Cancel', 'GL', 'Simple']
, defaultButton = 'Simple'
, cancelButton = 'Cancel'
, dismissString = 'Cancel')
if choice == 'Simple':
simpleBlast(name, startFrame, endFrame)
elif choice == 'GL':
glBlast(name, startFrame, endFrame)
示例4: initializeBakeRange
def initializeBakeRange():
"""
Initialize bake anim range based on playback timeline min/max.
"""
start = cmds.playbackOptions(q=True, min=True)
end = cmds.playbackOptions(q=True, max=True)
cmds.intFieldGrp('xferMocap_startEndCBG', e=True, v1=start, v2=end)
示例5: getMinMax
def getMinMax():
rangeStart = cmds.playbackOptions(query=True, minTime=True)
rangeEnd = cmds.playbackOptions(query=True, maxTime=True)
curvesShown = cmds.animCurveEditor( 'graphEditor1GraphEd', query=True, curvesShown=True)
keysTimes = []
keysValues = []
keysShown = []
if curvesShown:
for aCurve in curvesShown:
keysTimes.extend(cmds.keyframe(aCurve, query=True, timeChange=True))
keysValues.extend(cmds.keyframe(aCurve, query=True, valueChange=True))
for n, key in enumerate(keysTimes):
if rangeStart <= key <= rangeEnd:
keysShown.append(keysValues[n])
keyMax = max(keysShown)
keyMin = min(keysShown)
total = keyMax - keyMin
if total == 0: total = 1
border = total * .1
return [keyMax+border, keyMin-border]
else:
return [0, 100]
示例6: getCurrent
def getCurrent(self):
self.minframe = int( mc.playbackOptions(q = True, min = True) )
self.maxframe = int( mc.playbackOptions(q = True, max = True) )
self.totalframes = self.maxframe - self.minframe + 1
t = mc.currentUnit(q = True, t = True)
self.fps = self._mfps[t]
return True
示例7: __init__
def __init__(self, shotAssetPath, shot):
super(CameraExportWidget, self).__init__()
self.setLayout(QtGui.QVBoxLayout())
widgetLayout = QtGui.QGridLayout()
self.layout().addLayout(widgetLayout)
widgetLayout.addWidget(QtGui.QLabel('Select Camera:'), 0, 0)
self.cameraBox = QtGui.QComboBox()
self.populateCameraBox()
widgetLayout.addWidget(self.cameraBox, 0, 1)
widgetLayout.addWidget(QtGui.QLabel('Frame Start'), 1, 0)
self.frameStartEdit = QtGui.QLineEdit()
self.frameStartEdit.setText(str(cmds.playbackOptions(q=True, minTime=True)))
widgetLayout.addWidget(self.frameStartEdit, 1, 1)
widgetLayout.addWidget(QtGui.QLabel('Frame End'), 1, 2)
self.frameEndEdit = QtGui.QLineEdit()
self.frameEndEdit.setText(str(cmds.playbackOptions(q=True, maxTime=True)))
widgetLayout.addWidget(self.frameEndEdit, 1, 3)
widgetLayout.addWidget(QtGui.QLabel('Frame Step'), 2, 0)
self.frameStepEdit = QtGui.QLineEdit()
self.frameStepEdit.setText('1')
widgetLayout.addWidget(self.frameStepEdit, 2, 1)
fileLayout = QtGui.QHBoxLayout()
fileLayout.addWidget(QtGui.QLabel('Output File:'))
self.outFileEdit = QtGui.QLineEdit()
camFilePath = ''
if shotAssetPath and shot:
camFilePath = self.getOutputFilename(shot, shotAssetPath)
self.outFileEdit.setText(camFilePath)
fileLayout.addWidget(self.outFileEdit)
toolButton = QtGui.QToolButton()
toolButton.setText('...')
toolButton.clicked.connect(lambda: self.saveOutputFilename(camFilePath))
fileLayout.addWidget(toolButton)
self.layout().addLayout(fileLayout)
示例8: 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
}
示例9: playblast_scene
def playblast_scene():
""" Playblast the current scene using the min and max playback
values as the start and end value for the playblast.
:todo: Add a configuration (json) file that lets the user save
their file to a particular location.
:todo: Add a function in the utils folder that time stamps or
versions the maya file.
"""
# Get the start and end frames of the animation scene:
start_frame = cmds.playbackOptions(min=True, query=True)
end_frame = cmds.playbackOptions(max=True, query=True)
# Create the filename of the playblast:
time_code = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())
filename = cmds.file(query=True, sceneName=True)
filename += time_code
filename += ".mov"
location = os.path.join(_get_images_directory(), filename)
# Playblast the scene:
cmds.playblast(filename=location, fmt="qt", offScreen=True)
# Return
return
示例10: export_cameras
def export_cameras(self, assets_path, project):
valid_cameras = None
selected_cameras = cmds.ls(sl=True, dag=True, ca=True)
for cam in selected_cameras:
if cam != "perspShape" and cam != "topShape" and cam != "frontShape" and cam != "sideShape":
valid_cameras = True
if not valid_cameras:
cmds.inViewMessage(
amg="No valid cameras selected (default 'persp' camera not supported in FBX export)",
pos='botCenter', fade=True, fadeOutTime=500)
return
start_frame = str(cmds.playbackOptions(query=True, minTime=True))
end_frame = str(cmds.playbackOptions(query=True, maxTime=True))
if not os.path.exists(assets_path + "/" + project):
os.makedirs(assets_path + "/" + project)
output_file = assets_path + "/" + project + "/" + project + "_cameras.fbx"
print "Camera file name: " + output_file
# save the cameras to assets folder
maya.mel.eval('FBXExportFileVersion "FBX201200"')
maya.mel.eval('FBXExportInAscii -v true')
maya.mel.eval("FBXExportCameras -v true")
cmds.file(output_file, force=True, options='v=0', type='FBX export', pr=True, es=True)
return [output_file, start_frame, end_frame]
示例11: go
def go():
try:
assetName, assetType, version = geo.decodeFileName()
except IndexError:
showErrorDialog()
return
if not assetType == "animation":
showErrorDialog()
return
fileName = mc.file(q=True, sceneName=True)
dirName = os.path.dirname(fileName)
source = amu.getCheckinDest(dirName)
blastPath = os.path.join(os.path.dirname(source), "playblasts")
name = os.path.join(blastPath, assetName)
startFrame = mc.playbackOptions(q=True, min=True)
endFrame = mc.playbackOptions(q=True, max=True)
choice = mc.confirmDialog(
title="Playblast Tool",
message="What kind of playblast?",
button=["Cancel", "GL", "Simple"],
defaultButton="Simple",
cancelButton="Cancel",
dismissString="Cancel",
)
if choice == "Simple":
simpleBlast(name, startFrame, endFrame)
elif choice == "GL":
glBlast(name, startFrame, endFrame)
示例12: __init__
def __init__(self, resolution=[1920, 1080, 1.0], range=[]):
self.userName = "Max"
self.resolution = resolution
self.curPanel = cmds.getPanel(wf=True)
self.userName = "Unknown"
self.settings = fn.loadSettings(fileName)
if "display" in self.settings:
self.userName = self.settings["display"]
curDate = time.localtime()
self.curTime = "%02d:%02d %02d.%02d.%04d" % (
curDate.tm_hour,
curDate.tm_min,
curDate.tm_mday,
curDate.tm_mon,
curDate.tm_year,
)
if range:
self.range = range
else:
self.range = [cmds.playbackOptions(q=True, min=True), cmds.playbackOptions(q=True, max=True)]
self.duration = int(self.range[1] - self.range[0] + 1)
self.getFileName()
self.getFPS()
示例13: LoadJointMotionPaths
def LoadJointMotionPaths( self, roots ):
""" prep the data structure that holds the motion paths """
animPaths = {}
for root in roots:
animPaths[root] = {}
self.trace[root] = Trajectory("%sTrace"%root)
# find all nearby joints
joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs] # TODO: just get the nearby joints by projecting them all onto the viewing plane and finding the distance
# get the motion path of each nearby joint
if len(joints) > 0:
for j in joints:
animPaths[root][j] = Trajectory( "%s_path"%j )
if debug > 0:
mc.group(name="%sGrp"%j,empty=True)
startFrame = mc.playbackOptions(q=True,minTime=True)
endFrame = mc.playbackOptions(q=True,maxTime=True)+1
for t in [float(x)/self.substeps+startFrame for x in range(0, int(endFrame-startFrame)*self.substeps)]:
mc.currentTime(t)
for root in roots:
joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]
for j in joints:
point = Vector( mc.xform(j, q=True, ws=True, t=True) )
animPaths[root][j].AddPoint( point, t )
if debug > 0:
loc = mc.spaceLocator(p=point)
mc.parent(loc,"%sGrp"%j)
self.trace[root].SetSearchList( animPaths[root] )
示例14: TraceGestureRelease
def TraceGestureRelease( self ):
""" when the mouse is released, find the matching joint trajectory """
if debug>0: print("begin RELEASE")
releasePosition = Vector( mc.draggerContext( 'TraceGesture', query=True, dragPoint=True) ).projectToPlane( self.trace[self.nearestRoot].normal, planePt=self.trace[self.nearestRoot].planePt )
if debug>0: print "release! ", releasePosition
theTrace = self.trace[self.nearestRoot]
selectedMotion = None
if theTrace.closestJoint and theTrace.timespan and (theTrace.timespan[1]-theTrace.timespan[0]) > 1 and \
not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":
theDTW = theTrace.dtws[theTrace.closest]
if debug > 0:
print "closest = ", theTrace.closestJoint, theTrace.timespan
if not mc.objExists("DTW_Y"):
mc.group(n="DTW_Y",empty=True)
for pt in theDTW.Y:
loc = mc.spaceLocator(p=pt)
mc.parent(loc,"DTW_Y")
## ghostJoint(trace[nearestRoot].closestJoint,trace[nearestRoot].timespan)
# Build the motion curve and store it's name in the selectedMotions dictionary
duration = [ int(theTrace.timespan[0]), int(theTrace.timespan[1]+1) ]
keyframes = [ theTrace.searchList[theTrace.closestJoint].points[frame] for frame in range(duration[0],duration[1]) ]
selectedMotion = bmt.CurveMotionTrace( theTrace.closestJoint, keys=keyframes ) #duration=theTrace.timespan )
else:
self.ScrubToNearestTimeOnPath( releasePosition, self.nearestRoot, self.nearestPath )
cam2pop = self.CameraToPopDist()
path = theTrace.searchList[self.nearestPath]
pointKey = path.ClosestTimeTo(releasePosition)
closestPoint = path.points[pointKey]
closestPtOnPath = closestPoint.projectToPlane( theTrace.normal, planePt=theTrace.planePt )
mouse2path = (releasePosition - closestPtOnPath).mag()
# if motion paths are visible and no drag happened
# and releasePosition is very close to the path,
# then select the whole motion path
if self.motionPathsVisible[self.nearestRoot] and mouse2path < 0.3:
# Build the motion curve and store it's name in the selectedMotions dictionary
duration = [ mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)+1 ]
keyframes = [ theTrace.searchList[self.nearestPath].points[frame] for frame in range(duration[0],duration[1]) ]
selectedMotion = bmt.CurveMotionTrace( self.nearestPath, keys=keyframes ) #duration=[mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)] )
# if not scrubbing
if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl" and \
cam2pop >= self.viewFitDistance: # if trucked out, and mouse is clicked (w/ no drag)
mc.select(self.nearestRoot) # zoom in on the nearest root for a better view
mc.viewFit(fitFactor=2.5) # the invisible parts of the roots can artificially enlarge the BB, so truck in a little extra
mc.select(clear=True)
if selectedMotion:
selectedMotionCurve = selectedMotion.construct(self.nearestPath)
if not self.nearestRoot in self.selectedMotions.keys():
self.selectedMotions[self.nearestRoot] = []
mc.setAttr("%s_MotionTraces.visibility"%self.nearestRoot, 0)
selectedMotionCurve = mc.rename(selectedMotionCurve, "%s_selection%d"%(self.nearestPath,len(self.selectedMotions[self.nearestRoot])))
self.selectedMotions[self.nearestRoot].append( selectedMotionCurve )
self.AddCustomAttr( selectedMotionCurve, "isTraceSelection", True )
self.AddCustomAttr( selectedMotionCurve, "interactTime", time.time()-self.startTime )
self.AddCustomAttr( selectedMotionCurve, "startFrame", duration[0] )
self.AddCustomAttr( selectedMotionCurve, "endFrame", duration[1] )
mc.select(cl=True)
示例15: exportAlembic
def exportAlembic():
msgText = ""
SAVE_PATH = os.path.dirname(cmds.file(q=True,sn=True))
SAVE_PATH = SAVE_PATH.replace("WORK", "PUBLISH")
SAVE_FILE = os.path.basename(cmds.file(q=True,sn=True))
if (len(SAVE_FILE.split('_')) > 2):
tmpFile = SAVE_FILE.split('_')
SAVE_FILE = tmpFile[0] + "_" + tmpFile[1]
SAVE_DIR = (SAVE_PATH + '\\' + SAVE_FILE.split('.')[0] + ".abc").replace("\\","/")
FRAME_START = cmds.playbackOptions( query=True, animationStartTime=True )
FRAME_END = cmds.playbackOptions( query=True, animationEndTime=True )
try:
mel.eval('select -r ASSETS ;')
mel.eval('select -add CAM ;')
mel.eval('AbcExport -j "-frameRange ' + str(FRAME_START) + ' ' + str(FRAME_END) + ' -attr name -dataFormat hdf -root |ASSETS -root |CAM -file ' + SAVE_DIR + '";')
msgText = "** DONE | ALEMBIC EXPORT: " + SAVE_DIR.replace("/","\\") + " **"
print(msgText)
except:
msgText = "** FAIL | ALEMBIC EXPORT: No ASSETS & CAM group in the scene **"
print(msgText)
return msgText