本文整理汇总了Python中maya.cmds.playblast函数的典型用法代码示例。如果您正苦于以下问题:Python playblast函数的具体用法?Python playblast怎么用?Python playblast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了playblast函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playblastStart
def playblastStart(cameraList):
for x in cameraList:
i = cmds.listRelatives( x, p=True )
cmds.select(i)
start = cmds.findKeyframe( i, which="first" )
end = cmds.findKeyframe( i, which="last" )
sceneNameFull = cmds.file(query = True, shortName = True, sceneName = True)
if '.mb' in sceneNameFull or '.ma' in sceneNameFull:
sceneName = sceneNameFull[:-3]
else:
sceneName = sceneNameFull
cmds.select(cl = 1)
focus = cmds.getPanel( withFocus=True )
cmds.modelPanel( focus, edit=True, camera = x )
cmds.modelEditor( focus, edit = True, cameras = False, locators = False)
print start, end
if start == end: # this means there's no keyframes
print 'no keyframes on this one, playblasting timeline duration'
cmds.playblast (format = "qt", compression = "Sorenson Video 3", filename = desktop + sceneName + '_' + str(i[0]) + '.mov', clearCache = 1 , viewer = 0, showOrnaments = 1, fp = 4, percent = 100, quality = 100, widthHeight = [1280, 720])
else:
print 'keyframes found, playblasting their start to end'
cmds.playblast (startTime = start, endTime = end, format = "qt", compression = "Sorenson Video 3", filename = desktop + sceneName + '_' + str(i[0]) + '.mov', sequenceTime = 0, clearCache = 1 , viewer = 0, showOrnaments = 1, fp = 4, percent = 100, quality = 100, widthHeight = [1280, 720])
#cmds.playblast( completeFilename = str(i) + '.mov', startTime = start, endTime = end, viewer = True, clearCache = True, percent = 100, quality = 100, format = "qt", framePadding = 20 )
cmds.modelEditor( focus, edit = True, cameras = True, locators = True)
print ' moving to the next one '
示例2: playblast
def playblast(self, filename, **kwargs):
'''Playblasting with reasonable default arguments. Automatically sets
this viewport to the active view, ensuring that we playblast the
correct view.
:param filename: Absolute path to output file
:param kwargs: Same kwargs as :func:`maya.cmds.playblast`'''
playblast_kwargs = {
'filename': filename,
'offScreen': False,
'percent': 100,
'quality': 100,
'viewer': True,
'width': 960,
'height': 540,
'framePadding': 4,
'format': 'qt',
'compression': 'H.264',
'forceOverwrite': True,
}
playblast_kwargs.update(kwargs)
if not self.focus:
self.focus = True
cmds.playblast(**playblast_kwargs)
示例3: blast
def blast(*args):
"""Playblast and settings. Change to your liking."""
fileNameLong = cmds.file(query=True, sceneName=True, shortName=True)
if fileNameLong == "":
fileNameLong = "untitled"
else:
fileNameLong = cmds.file(query=True, sceneName=True, shortName=True)
fileNameShort = fileNameLong.split(".")
TimeRange = mel.eval('$tmpVar=$gPlayBackSlider')
SoundNode = cmds.timeControl(TimeRange, query=True, sound=True)
# Disable 2D Pan & Zoom in current viewport
activepanel = cmds.getPanel(withFocus=True)
cam = cmds.modelEditor(activepanel, query=True, camera=True)
# camShape = cmds.listRelatives(cam, shapes=True)[0]
cmds.setAttr(cam + '.panZoomEnabled', False)
if cmds.ls(renderResolutions=True):
ResX = cmds.getAttr("defaultResolution.width")
ResY = cmds.getAttr("defaultResolution.height")
cmds.playblast(
filename=("movies/" + fileNameShort[0] + ".mov"),
forceOverwrite=True, format="qt", compression="png",
offScreen=True, width=ResX, height=ResY, quality=100,
percent=100, sound=SoundNode
)
else:
cmds.error("No resolution data in file. \
Please set resolution and save.")
示例4: save_scene
def save_scene(search_key, context, description, all_process):
# add info about particular scene
skey_link = 'skey://{0}&context={1}'.format(search_key, context)
if not cmds.attributeQuery('tacticHandler_skey', node='defaultObjectSet', exists=True):
cmds.addAttr('defaultObjectSet', longName='tacticHandler_skey', dataType='string')
cmds.setAttr('defaultObjectSet.tacticHandler_skey', skey_link, type='string')
# get template names for scene and playblast image
temp_dir = env.Env().get_temp_dir()
random_uuid = uuid.uuid4()
types = {
'mayaBinary': 'mb',
'mayaAscii': 'ma',
}
temp_file = '{0}/{1}.ma'.format(temp_dir, random_uuid)
temp_playblast = '{0}/{1}.jpg'.format(temp_dir, random_uuid)
# rename file, save scene, playblast, get saving format
cmds.file(rename=temp_file)
cmds.file(save=True, type='mayaAscii')
current_frame = cmds.currentTime(query=True)
cmds.playblast(
forceOverwrite=True,
format='image',
completeFilename=temp_playblast,
showOrnaments=False,
widthHeight=[960, 540],
sequenceTime=False,
frame=[current_frame],
compression='jpg',
offScreen=True,
viewer=False,
percent=100
)
# check in snapshot
snapshot = tc.checkin_snapshot(search_key, context, temp_file, file_type='maya', is_current=True,
description=description)
# from pprint import pprint
# pprint(snapshot)
# retrieve checked in snapshot file info
asset_dir = env.Env().get_asset_dir()
file_sobject = snapshot['__file_sobjects__'][0]
relative_dir = file_sobject['relative_dir']
file_name = file_sobject['file_name']
# make proper file path, and dir path to set workspace
new_file = '{0}/{1}/{2}'.format(asset_dir, relative_dir, file_name)
split_path = relative_dir.split('/')
dir_path = '{0}/{1}'.format(asset_dir, '{0}/{1}/{2}'.format(*split_path))
set_workspace(dir_path, all_process)
# check in playblast
tc.checkin_playblast(snapshot['code'], temp_playblast)
# set proper scene name
cmds.file(rename=new_file)
示例5: ScreenCapture
def ScreenCapture(filename,resolution, color = 0.361):
cmds.undoInfo(stateWithoutFlush = False)
try:
oldFormat = cmds.getAttr("defaultRenderGlobals.imageFormat")
cmds.setAttr("defaultRenderGlobals.imageFormat", 32)
#Store the current display colors
colors = [cmds.displayRGBColor("background", query = True),
cmds.displayRGBColor("backgroundTop", query = True),
cmds.displayRGBColor("backgroundBottom", query = True)]
#To make the UI prettier
cmds.displayRGBColor("background", color, color, color)
cmds.displayRGBColor("backgroundTop", color, color, color)
cmds.displayRGBColor("backgroundBottom", color, color, color)
#Take a snap for the UI
cmds.playblast(frame=0,fmt="image",viewer=0,fp=4,orn=0,p=100,wh=resolution,ifz=0,fo=1,offScreen=1,cf=filename)
#Revert to the old colors
cmds.displayRGBColor("background", colors[0][0], colors[0][1], colors[0][2])
cmds.displayRGBColor("backgroundTop", colors[1][0], colors[1][1], colors[1][2])
cmds.displayRGBColor("backgroundBottom", colors[2][0], colors[2][1], colors[2][2])
cmds.setAttr("defaultRenderGlobals.imageFormat", oldFormat)
except:
pass
cmds.undoInfo(stateWithoutFlush = True)
示例6: playblastLocal
def playblastLocal(blastFilename, format, start, end, offscreen, width, height):
'''
Perform a playblast.
'''
# Check
if format not in IMAGE_FORMAT_DICT:
raise ImageFormatException, 'Invalid image format: %s' % format
# Set the image format from the list and backup the old one
oldRenderFormat = cmds.getAttr('defaultRenderGlobals.imageFormat')
cmds.setAttr('defaultRenderGlobals.imageFormat', IMAGE_FORMAT_DICT[format])
# Do the blast
cmds.playblast(filename=blastFilename,
format='image',
startTime=start,
endTime=end,
forceOverwrite=True,
viewer=False,
offScreen=offscreen,
widthHeight=[int(width), int(height)],
percent=100
)
# Restore the old render globals image format
cmds.setAttr('defaultRenderGlobals.imageFormat', oldRenderFormat)
示例7: recordPlayblastForSequenceN
def recordPlayblastForSequenceN(self, tab, level1, level2, level3, width , height , fileName ,sframe , eframe , folder = 'devFolder' ):
# "/Users/higgsdecay/test"
playblastFile = os.path.join(str(self.getFileName(tab, level1, level2, level3, folder , 0, 1)), "preview", os.path.splitext(str(fileName))[0], str(fileName))
# create the preview folder
previewFolder = os.path.dirname(playblastFile)
if not os.path.exists(previewFolder):
os.makedirs(previewFolder)
os.chmod( previewFolder , 0777 )
# startFrame = cmds.getAttr("defaultRenderGlobals.startFrame")
# endFrame = cmds.getAttr("defaultRenderGlobals.endFrame")
format = cmds.getAttr("defaultRenderGlobals.imageFormat")
# width = cmds.getAttr("defaultResolution.width")
# height = cmds.getAttr("defaultResolution.height")
ratio = cmds.getAttr("defaultResolution.deviceAspectRatio")
cams = [ x for x in cmds.ls(typ='camera') if cmds.getAttr(x+'.renderable')]
thecam = cmds.listRelatives( cams[0] , p = 1) if cams != [] else None
cmds.setAttr("defaultRenderGlobals.imageFormat", 8)
# playblast -startTime 1 -endTime 10 -format iff -filename "/Users/higgsdecay/output/ACR_rig_v02_w03"
#-forceOverwrite -sequenceTime 0 -clearCache 0 -viewer 1 -showOrnaments 1 -fp 4 -percent 50 -widthHeight 1920 1080;
cmds.playblast(startTime=sframe, endTime=eframe, format="image",percent = 100 , qlt = 100,
filename=os.path.splitext(str(playblastFile))[0], showOrnaments=False, viewer=False, os=1,
sequenceTime=False, forceOverwrite=True,
widthHeight=[int(width), int(height)] )
for x in glob.glob( previewFolder+os.sep+'*.*' ):
print 'glob : ' , x
os.chmod(x , 0777)
cmds.setAttr("defaultRenderGlobals.imageFormat", format)
return (playblastFile, ratio)
示例8: 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
示例9: recordPlayblastForSequence
def recordPlayblastForSequence(self, tab, level1, level2, level3, offset=0, archive=0):
# "/Users/higgsdecay/test"
playblastFile = self.getFileName(tab, level1, level2, level3, "playblastFile2", offset, archive)
# create the preview folder
previewFolder = os.path.dirname(playblastFile)
if not os.path.exists(previewFolder):
os.makedirs(previewFolder)
os.chmod( previewFolder , 0777 )
else :
os.chmod( previewFolder , 0777 )
startFrame = cmds.getAttr("defaultRenderGlobals.startFrame")
endFrame = cmds.getAttr("defaultRenderGlobals.endFrame")
format = cmds.getAttr("defaultRenderGlobals.imageFormat")
width = cmds.getAttr("defaultResolution.width")
height = cmds.getAttr("defaultResolution.height")
ratio = cmds.getAttr("defaultResolution.deviceAspectRatio")
cmds.setAttr("defaultRenderGlobals.imageFormat", 8)
# playblast -startTime 1 -endTime 10 -format iff -filename "/Users/higgsdecay/output/ACR_rig_v02_w03"
#-forceOverwrite -sequenceTime 0 -clearCache 0 -viewer 1 -showOrnaments 1 -fp 4 -percent 50 -widthHeight 1920 1080;
cmds.playblast(startTime=startFrame, endTime=endFrame, format="image",
filename=str(playblastFile), showOrnaments=False, viewer=False, percent=100,os=1,
sequenceTime=False, forceOverwrite=True,
widthHeight=[int(width), int(height)])
cmds.setAttr("defaultRenderGlobals.imageFormat", format)
return (playblastFile+".####.jpg", int(startFrame), int(endFrame), int(width), int(height), ratio)
示例10: 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)
示例11: createThumbnailN
def createThumbnailN(self, tab, level1, level2, level3, fileName):
fileName = self.getFileName(tab, level1, level2, level3, "sceneFolder", 0, 1)+fileName
currFrame = cmds.currentTime(query=True)
format = cmds.getAttr("defaultRenderGlobals.imageFormat")
cmds.setAttr("defaultRenderGlobals.imageFormat", 8)
cmds.playblast(frame=currFrame, format="image", completeFilename=str(fileName), showOrnaments=False, viewer=False, widthHeight=[164, 105], percent=100 , os=1)
cmds.setAttr("defaultRenderGlobals.imageFormat", format)
return fileName
示例12: writeFile
def writeFile(self,*args):
self.infoDict = {} #redefines self.infoDict
self.selection = cmds.ls(sl = True) #gets names of selected objects
poseQuery = cmds.textFieldGrp(self.fileName, q = True, text = True) #queries the pose name text field
charQuery = cmds. textScrollList(self.folderName, q = True, selectItem = True) #queries the folder name text scroll list
if self.selection == []: #if selection is empty, raises a warning
cmds.warning('Please make a selection!!')
elif not poseQuery: #if pose is not named, raises a warning
cmds.warning('Please name the pose!!')
if not charQuery: #if a character is not selected, raises a warning
cmds.warning('Please select a character!!')
poses = os.listdir(self.fileLoc + '/Characters/'+ charQuery[0]) #gets files in directory
poseFile =('POSE_' + poseQuery + '.txt') #gets pose name
if poseFile in poses: # if a file with the same name already exists, raises a warning.
cmds.warning('There is already a pose with that name!!')
return False
else: #else: runs writeFile
cmds.select(cl=True) #clears selection
self.outputDict()
# Get file name from user and write to file
self.fileNameQuery = cmds.textFieldGrp(self.fileName,query=True,text=True) #queries the file name
if (self.fileNameQuery =='') or (self.fileNameQuery == 'Please enter desired file name'):
cmds.warning('Please name the file!') #if the text box is empy, requests input.
else:
self.folderQuery = cmds.textScrollList(self.folderName, q = True, selectItem = True) #Queries the text scroll list for character name
self.listFiles = os.listdir(self.fileLoc + "/Characters") #lists files in the characters directory
if not self.folderQuery: #if there's nothing selected, raises a warning
cmds.warning('Select a character!!')
else:
self.listSubFiles = os.listdir(self.fileLoc + '/Characters/' + self.folderQuery[0]) #lists the files in the character folder
self.listToAdd = [] #defines listToAdd
cmds.textScrollList(self.poseToLoad, e= True, removeAll = True) #empties the textScrollList
with open(self.fileLoc + '/Characters/' +self.folderQuery[0] + '/POSE_' + self.fileNameQuery + '.txt', "w+") as fileOpen: #opens the file
fileOpen.write(cPickle.dumps (self.infoDict)) #dumps cpickle into file
fileOpen.close() #closes file
charQuery = cmds.textScrollList(self.folderName, q = True, selectItem = True) #Queries the character name
poseQuery = cmds.textFieldGrp(self.fileName, q = True, text = True) #queries the pose name
picName = (self.fileLoc + '/Images/'+ charQuery[0] + '/POSE_' + poseQuery) # defines pic name
picNameB = (picName) #is useless
cmds.playblast(format = 'image', frame = 1, f = picNameB) #creates image for preview
self.listDir = os.listdir(self.fileLoc + "/Characters/" + self.folderQuery[0]) # lists the directory
# Update option Menu
#if item is not in the list, adds it to directory
if not self.folderQuery:
cmds.warning('Please select a character!!')
else:
for items in os.listdir(self.fileLoc + "/Characters/"+ self.folderQuery[0]):# for every item in the pose directory
if items not in self.listToAdd:#if the item is not in the list to add
self.listToAdd.append(items) #adds it to the list
cmds.deleteUI(self.poseToLoad) # delete the UI element
self.poseToLoad = cmds.textScrollList(parent = self.refreshLayout, numberOfRows=8, allowMultiSelection= False, append = self.listToAdd, sc = self.refreshPic, en = True) #recreates the UI element
else:
cmds.warning('There is already a pose with that name!') #raises a warning
if not self.folderQuery:
cmds.warning('Please Select a character') #raises a warning
示例13: get_thumbnail
def get_thumbnail(self):
for camera in mc.listCameras():
if camera == "persp":
pass
else:
mm.eval("viewFit -all;")
mc.lookThru(camera)
mc.playblast( cf= "H:\\Image Test\\" + camera + ".jpg" , fr=1, fmt="image", v=False, wh=[500, 300], orn=False,
compression="jpg", quality=100, percent=100 )
示例14: snapshot
def snapshot(path = None, width = 96, height = 96):
current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png
#path = "/Users/liorbenhorin/Library/Preferences/Autodesk/maya/2015-x64/scripts/pipeline/thumb.png"
cmds.playblast(cf = path, fmt="image", frame = cmds.currentTime( query=True ), orn=False, wh = [width,height], p=100, v=False)
cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format)
if os.path.isfile(path):
return path
else:
return False
示例15: _generate_quicktime
def _generate_quicktime(quicktime_path):
"""
Returns a Quicktime object with info about the generated quicktime.
"""
quicktime_dir = os.path.dirname(quicktime_path)
if not os.path.exists(quicktime_dir):
try:
os.makedirs(quicktime_dir)
except os.error as e:
return Quicktime(
success=False,
error_msg=str(e),
frame_count=None,
frame_range=None,
first_frame=None,
last_frame=None,
path=None,
)
# use the min/max frames from frame slider
first_frame = int(cmds.playbackOptions(query=True, minTime=True))
last_frame = int(cmds.playbackOptions(query=True, maxTime=True))
# initiate the playblast
try:
cmds.playblast(
compression="jpeg",
endTime=last_frame,
filename=quicktime_path,
forceOverwrite=True,
format="movie",
offScreen=True,
startTime=first_frame,
viewer=False,
)
except Exception as e:
error_msg = str(e)
success = False
else:
error_msg = None
success = True
# return all the info for the new quicktime
return Quicktime(
success=success,
error_msg=error_msg,
frame_count=int(last_frame - first_frame + 1),
frame_range="{f}-{l}".format(f=first_frame, l=last_frame),
first_frame=first_frame,
last_frame=last_frame,
path=quicktime_path,
)