def playblast(filename, modelPanel, startFrame, endFrame, width, height, step = 1): """ :type path: str :type modelPanel: str :type start: int :type end: int :type width: int :type height: int :type step: list[int] :rtype: str """ logger.info("Playblasting '%s'" % filename) if startFrame == endFrame and os.path.exists(filename): os.remove(filename) frame = [ i for i in range(startFrame, endFrame + 1, step) ] modelPanel = modelPanel or mutils.currentModelPanel() if maya.cmds.modelPanel(modelPanel, query=True, exists=True): maya.cmds.setFocus(modelPanel) name, compression = os.path.splitext(filename) filename = filename.replace(compression, '') compression = compression.replace('.', '') offScreen = mutils.isLinux() path = maya.cmds.playblast(format='image', viewer=False, percent=100, quality=100, frame=frame, width=width, height=height, filename=filename, endTime=endFrame, startTime=startFrame, offScreen=offScreen, forceOverwrite=True, showOrnaments=False, compression=compression) if not path: raise PlayblastError('Playblast was canceled') src = path.replace('####', str(int(0)).rjust(4, '0')) if startFrame == endFrame: dst = src.replace('.0000.', '.') logger.info("Renaming '%s' => '%s" % (src, dst)) os.rename(src, dst) src = dst logger.info("Playblasted '%s'" % src) return src
def playblast(path, modelPanel, start, end, frame, width, height): """ :type path: str :type modelPanel: str :type start: int :type end: int :type width: int :type height: int :type frame: list[int] :rtype: str """ logger.info("Playblasting '%s'" % path) if start == end and os.path.exists(path): os.remove(path) maya.cmds.setFocus(modelPanel or mutils.currentModelPanel()) name, compression = os.path.splitext(path) path = path.replace(compression, '') compression = compression.replace('.', '') path = maya.cmds.playblast(format='image', viewer=False, percent=100, startTime=start, endTime=end, quality=100, offScreen=mutils.isLinux(), forceOverwrite=True, width=width, height=height, showOrnaments=False, compression=compression, filename=path, frame=frame) if not path: raise SnapshotError('Playblast was canceled') src = path.replace('####', str(int(0)).rjust(4, '0')) if start == end: dst = src.replace('.0000.', '.') logger.info("Renaming '%s' => '%s" % (src, dst)) os.rename(src, dst) src = dst logger.info("Playblasted '%s'" % src) return src
def playblast(filename, modelPanel, startFrame, endFrame, width, height, step=1): """ Wrapper for Maya's Playblast command. :type filename: str :type modelPanel: str :type startFrame: int :type endFrame: int :type width: int :type height: int :type step: list[int] :rtype: str """ logger.info("Playblasting '{filename}'".format(filename=filename)) if startFrame == endFrame and os.path.exists(filename): os.remove(filename) frame = [i for i in range(startFrame, endFrame + 1, step)] modelPanel = modelPanel or mutils.currentModelPanel() if maya.cmds.modelPanel(modelPanel, query=True, exists=True): maya.cmds.setFocus(modelPanel) if DEFAULT_PLAYBLAST_RENDERER: maya.cmds.modelEditor(modelPanel, edit=True, rendererName=DEFAULT_PLAYBLAST_RENDERER) name, compression = os.path.splitext(filename) filename = filename.replace(compression, "") compression = compression.replace(".", "") offScreen = mutils.isLinux() path = maya.cmds.playblast( format="image", viewer=False, percent=100, quality=100, frame=frame, width=width, height=height, filename=filename, endTime=endFrame, startTime=startFrame, offScreen=offScreen, forceOverwrite=True, showOrnaments=False, compression=compression, ) if not path: raise PlayblastError("Playblast was canceled") src = path.replace("####", str(int(0)).rjust(4, "0")) if startFrame == endFrame: dst = src.replace(".0000.", ".") logger.info("Renaming '%s' => '%s" % (src, dst)) os.rename(src, dst) src = dst logger.info("Playblasted '%s'" % src) return src