本文整理汇总了Python中maya.cmds.playblast方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.playblast方法的具体用法?Python cmds.playblast怎么用?Python cmds.playblast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.playblast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playblast_snapshot
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def playblast_snapshot(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png
if range is None:
range = playback_selection_range()
print range
if range is None:
start = cmds.playbackOptions( q=True,min=True )
end = cmds.playbackOptions( q=True,max=True )
range = [start, end]
cmds.playblast(frame =int((range[0] + range[1])/2), cf = path, fmt="image", orn=hud, os=offscreen, wh = scene_resolution(), p=scale, v=False)
cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format)
示例2: runPB
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def runPB(quality, sequence, autoReview):
#Get the file unix path of the maya file
filePath = cmds.file(q=True, sceneName=True)
#Parse the unix path and convert it into a dpa fspattern
if quality < 50:
print "Lower than 50 percent quality may result in very poor imaging..."
cmds.deleteUI("PBQuality")
return
print "Percentage chosen: " + str(quality)
print "From Sequence: " + str(sequence)
print "AutoSubmit: " + str(autoReview)
#Attempts to create a playblast of the current maya scene
success = playblaster(quality, sequence, autoReview)
if success:
print "Successfully generated playblast :)"
else:
print "Failed to generate playblast :("
示例3: saveScreenshot
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def saveScreenshot(self, name, directory=DIRECTORY):
path = os.path.join(directory, '%s.jpg' % name)
# We'll fit the view to the objects in our scene or our selection
cmds.viewFit()
# We'll change our render format to jpg
cmds.setAttr("defaultRenderGlobals.imageFormat", 8) # This is the value for jpeg
# Finally we'll save out our image using the playblast module
# There are a lot of arguments here so it's good to use the documentation to know what's going on
cmds.playblast(completeFilename=path, forceOverwrite=True, format='image', width=200, height=200,
showOrnaments=False, startTime=1, endTime=1, viewer=False)
# Return the path of the file we saved
return path
# This will be our first Qt UI!
# We'll be creating a dialog, so lets start by inheriting from Qt's QDialog
示例4: playblast_dialog
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def playblast_dialog():
# Creates a dialog prompt to determine if the user wishes to create a playblast
#response = cmds.confirmDialog( title='Playblast', message='Are you SURE you want to create a new playblast?', button=['Yes','No'], defaultButton='No', cancelButton='No', dismissString='No' )
#if response == 'Yes':
floatUI()
示例5: snapshot
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
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
示例6: playblast
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def playblast(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
if range is None:
range = playback_selection_range()
print range
if range is None:
start = cmds.playbackOptions( q=True,min=True )
end = cmds.playbackOptions( q=True,max=True )
range = [start, end]
cmds.playblast(startTime =range[0] ,endTime =range[1], f = path, fmt=format, orn=hud, os=offscreen, wh = scene_resolution(), p=scale, qlt=90,c=compression, v=True, s = qeury_active_sound_node())
示例7: getPlayblastOptions
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def getPlayblastOptions():
options = {}
options["format"] = cmds.playblast(q=True,fmt=True)
options["compression"] = cmds.playblast(q=True,c=True)
return options
示例8: maintained_time
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def maintained_time():
"""Maintain current time during context
Example:
>>> with maintained_time():
... cmds.playblast()
>>> # Time restored
"""
ct = cmds.currentTime(query=True)
try:
yield
finally:
cmds.currentTime(ct, edit=True)
示例9: get_active_editor
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def get_active_editor():
"""Return the active editor panel to playblast with"""
# fixes `cmds.playblast` undo bug
cmds.currentTime(cmds.currentTime(query=True))
panel = cmds.playblast(activeEditor=True)
return panel.split("|")[-1]
示例10: _fix_playblast_output_path
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def _fix_playblast_output_path(filepath):
"""Workaround a bug in maya.cmds.playblast to return correct filepath.
When the `viewer` argument is set to False and maya.cmds.playblast does not
automatically open the playblasted file the returned filepath does not have
the file's extension added correctly.
To workaround this we just glob.glob() for any file extensions and assume
the latest modified file is the correct file and return it.
"""
# Catch cancelled playblast
if filepath is None:
log.warning("Playblast did not result in output path. "
"Playblast is probably interrupted.")
return
# Fix: playblast not returning correct filename (with extension)
# Lets assume the most recently modified file is the correct one.
if not os.path.exists(filepath):
directory = os.path.dirname(filepath)
filename = os.path.basename(filepath)
# check if the filepath is has frame based filename
# example : capture.####.png
parts = filename.split(".")
if len(parts) == 3:
query = os.path.join(directory, "{}.*.{}".format(parts[0],
parts[-1]))
files = glob.glob(query)
else:
files = glob.glob("{}.*".format(filepath))
if not files:
raise RuntimeError("Couldn't find playblast from: "
"{0}".format(filepath))
filepath = max(files, key=os.path.getmtime)
return filepath
示例11: capture_scene
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def capture_scene(options):
"""Capture using scene settings.
Uses the view settings from "panel".
This ensures playblast is done as quicktime H.264 100% quality.
It forces showOrnaments to be off and does not render off screen.
:param options: a collection of output options
:type options: dict
:returns: Full path to playblast file.
:rtype: str
"""
filename = options.get("filename", "%TEMP%")
log.info("Capturing to: {0}".format(filename))
options = options.copy()
# Force viewer to False in call to capture because we have our own
# viewer opening call to allow a signal to trigger between playblast
# and viewer
options['viewer'] = False
# Remove panel key since it's internal value to capture_gui
options.pop("panel", None)
path = capture.capture(**options)
path = _fix_playblast_output_path(path)
return path
示例12: browse
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def browse(path=None):
"""Open a pop-up browser for the user"""
# Acquire path from user input if none defined
if path is None:
scene_path = cmds.file(query=True, sceneName=True)
# use scene file name as default name
default_filename = os.path.splitext(os.path.basename(scene_path))[0]
if not default_filename:
# Scene wasn't saved yet so found no valid name for playblast.
default_filename = "playblast"
# Default to images rule
default_root = os.path.normpath(get_project_rule("images"))
default_path = os.path.join(default_root, default_filename)
path = cmds.fileDialog2(fileMode=0,
dialogStyle=2,
startingDirectory=default_path)
if not path:
return
if isinstance(path, (tuple, list)):
path = path[0]
if path.endswith(".*"):
path = path[:-2]
# Bug-Fix/Workaround:
# Fix for playblasts that result in nesting of the
# extension (eg. '.mov.mov.mov') which happens if the format
# is defined in the filename used for saving.
extension = os.path.splitext(path)[-1]
if extension:
path = path[:-len(extension)]
return path
示例13: default_output
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def default_output():
"""Return filename based on current scene name.
:returns: A relative filename
:rtype: str
"""
scene = get_current_scenename() or "playblast"
# get current datetime
timestamp = datetime.datetime.today()
str_timestamp = timestamp.strftime("%Y-%m-%d_%H-%M-%S")
filename = "{}_{}".format(scene, str_timestamp)
return filename
示例14: list_compressions
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def list_compressions(format='avi'):
# Workaround for Maya playblast bug where undo would
# move the currentTime to frame one.
cmds.currentTime(cmds.currentTime(query=True))
cmd = 'playblast -format "{0}" -query -compression'.format(format)
return mel.eval(cmd)
示例15: snap
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import playblast [as 别名]
def snap(*args, **kwargs):
"""Single frame playblast in an independent panel.
The arguments of `capture` are all valid here as well, except for
`start_frame` and `end_frame`.
Arguments:
frame (float, optional): The frame to snap. If not provided current
frame is used.
clipboard (bool, optional): Whether to add the output image to the
global clipboard. This allows to easily paste the snapped image
into another application, eg. into Photoshop.
Keywords:
See `capture`.
"""
# capture single frame
frame = kwargs.pop('frame', cmds.currentTime(q=1))
kwargs['start_frame'] = frame
kwargs['end_frame'] = frame
kwargs['frame'] = frame
if not isinstance(frame, (int, float)):
raise TypeError("frame must be a single frame (integer or float). "
"Use `capture()` for sequences.")
# override capture defaults
format = kwargs.pop('format', "image")
compression = kwargs.pop('compression', "png")
viewer = kwargs.pop('viewer', False)
raw_frame_numbers = kwargs.pop('raw_frame_numbers', True)
kwargs['compression'] = compression
kwargs['format'] = format
kwargs['viewer'] = viewer
kwargs['raw_frame_numbers'] = raw_frame_numbers
# pop snap only keyword arguments
clipboard = kwargs.pop('clipboard', False)
# perform capture
output = capture(*args, **kwargs)
def replace(m):
"""Substitute # with frame number"""
return str(int(frame)).zfill(len(m.group()))
output = re.sub("#+", replace, output)
# add image to clipboard
if clipboard:
_image_to_clipboard(output)
return output