def setModelPanelOptions(self): modelPanel = self.name() maya.cmds.modelEditor(modelPanel, edit=True, allObjects=False) maya.cmds.modelEditor(modelPanel, edit=True, grid=False) maya.cmds.modelEditor(modelPanel, edit=True, dynamics=False) maya.cmds.modelEditor(modelPanel, edit=True, activeOnly=False) maya.cmds.modelEditor(modelPanel, edit=True, manipulators=False) maya.cmds.modelEditor(modelPanel, edit=True, headsUpDisplay=False) maya.cmds.modelEditor(modelPanel, edit=True, selectionHiliteDisplay=False) maya.cmds.modelEditor(modelPanel, edit=True, polymeshes=True) maya.cmds.modelEditor(modelPanel, edit=True, nurbsSurfaces=True) maya.cmds.modelEditor(modelPanel, edit=True, subdivSurfaces=True) maya.cmds.modelEditor(modelPanel, edit=True, displayTextures=True) maya.cmds.modelEditor(modelPanel, edit=True, displayAppearance="smoothShaded") currentModelPanel = mutils.currentModelPanel() if currentModelPanel: camera = maya.cmds.modelEditor(currentModelPanel, query=True, camera=True) displayLights = maya.cmds.modelEditor(currentModelPanel, query=True, displayLights=True) displayTextures = maya.cmds.modelEditor(currentModelPanel, query=True, displayTextures=True) maya.cmds.modelEditor(modelPanel, edit=True, camera=camera) maya.cmds.modelEditor(modelPanel, edit=True, displayLights=displayLights) maya.cmds.modelEditor(modelPanel, edit=True, displayTextures=displayTextures)
def setModelPanelOptions(self): modelPanel = self.name() maya.cmds.modelEditor(modelPanel, edit=True, allObjects=False) maya.cmds.modelEditor(modelPanel, edit=True, grid=False) maya.cmds.modelEditor(modelPanel, edit=True, dynamics=False) maya.cmds.modelEditor(modelPanel, edit=True, activeOnly=False) maya.cmds.modelEditor(modelPanel, edit=True, manipulators=False) maya.cmds.modelEditor(modelPanel, edit=True, headsUpDisplay=False) maya.cmds.modelEditor(modelPanel, edit=True, selectionHiliteDisplay=False) maya.cmds.modelEditor(modelPanel, edit=True, polymeshes=True) maya.cmds.modelEditor(modelPanel, edit=True, nurbsSurfaces=True) maya.cmds.modelEditor(modelPanel, edit=True, subdivSurfaces=True) maya.cmds.modelEditor(modelPanel, edit=True, displayTextures=True) maya.cmds.modelEditor(modelPanel, edit=True, displayAppearance="smoothShaded") currentModelPanel = mutils.currentModelPanel() if currentModelPanel: camera = maya.cmds.modelEditor(currentModelPanel, query=True, camera=True) displayLights = maya.cmds.modelEditor(currentModelPanel, query=True, displayLights=True) displayTextures = maya.cmds.modelEditor(currentModelPanel, query=True, displayTextures=True) maya.cmds.modelEditor(modelPanel, edit=True, camera=camera) maya.cmds.modelEditor(modelPanel, edit=True, displayLights=displayLights) maya.cmds.modelEditor(modelPanel, edit=True, displayTextures=displayTextures)
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): """ :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 snapshot(path, start = None, end = None, width = 250, height = 250, step = 1, camera = None, modelPanel = None): """ :type path: str :type start: int :type end: int :type width: int :type height: int :type step: int :rtype: str """ if start is None: start = maya.cmds.currentTime(query=True) if end is None: end = start end = int(end) start = int(start) frame = [ i for i in range(start, end + 1, step) ] snapshotPanel = 'snapshotPanel' snapshotWindow = 'snapshotCamera' currentPanel = modelPanel or mutils.currentModelPanel() camera = camera or maya.cmds.modelEditor(currentPanel, query=True, camera=True) if maya.cmds.window(snapshotWindow, exists=True): maya.cmds.deleteUI(snapshotWindow) if maya.cmds.modelPanel(snapshotPanel, query=True, exists=True): maya.cmds.deleteUI(snapshotPanel, panel=True) snapshotWindow = maya.cmds.window(snapshotWindow, title=snapshotWindow, sizeable=False, minimizeButton=False, maximizeButton=False) maya.cmds.columnLayout('columnLayout') maya.cmds.paneLayout(width=width + 25, height=height + 25) snapshotPanel = maya.cmds.modelPanel(snapshotPanel, menuBarVisible=False, camera=camera) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, allObjects=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, grid=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, dynamics=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, activeOnly=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, manipulators=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, headsUpDisplay=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, selectionHiliteDisplay=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, polymeshes=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, nurbsSurfaces=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, subdivSurfaces=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, displayTextures=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, displayAppearance='smoothShaded') displayLights = maya.cmds.modelEditor(currentPanel, query=True, displayLights=True) maya.cmds.modelEditor(snapshotPanel, edit=True, displayLights=displayLights) maya.cmds.setParent('columnLayout') maya.cmds.button(label='Take Snapshot', width=width) rendererName = maya.cmds.modelEditor(currentPanel, query=True, rendererName=True) maya.cmds.modelEditor(snapshotPanel, edit=True, rendererName=rendererName) maya.cmds.window(snapshotWindow, edit=True, width=width, height=height + 25) maya.cmds.showWindow(snapshotWindow) try: path = playblast(path, snapshotPanel, start=start, end=end, frame=frame, width=width, height=height) finally: cmd = '\nimport maya.cmds;\nif maya.cmds.window("{window}", exists=True):\n maya.cmds.deleteUI("{window}", window=True)\n' cmd = cmd.format(window=snapshotWindow) maya.cmds.evalDeferred(cmd) return path
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
def snapshot(path, start=None, end=None, width=250, height=250, step=1, camera=None, modelPanel=None): """ :type path: str :type start: int :type end: int :type width: int :type height: int :type step: int :rtype: str """ if start is None: start = maya.cmds.currentTime(query=True) if end is None: end = start end = int(end) start = int(start) frame = [i for i in range(start, end + 1, step)] snapshotPanel = 'snapshotPanel' snapshotWindow = 'snapshotCamera' currentPanel = modelPanel or mutils.currentModelPanel() camera = camera or maya.cmds.modelEditor( currentPanel, query=True, camera=True) if maya.cmds.window(snapshotWindow, exists=True): maya.cmds.deleteUI(snapshotWindow) if maya.cmds.modelPanel(snapshotPanel, query=True, exists=True): maya.cmds.deleteUI(snapshotPanel, panel=True) snapshotWindow = maya.cmds.window(snapshotWindow, title=snapshotWindow, sizeable=False, minimizeButton=False, maximizeButton=False) maya.cmds.columnLayout('columnLayout') maya.cmds.paneLayout(width=width + 25, height=height + 25) snapshotPanel = maya.cmds.modelPanel(snapshotPanel, menuBarVisible=False, camera=camera) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, allObjects=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, grid=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, dynamics=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, activeOnly=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, manipulators=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, headsUpDisplay=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, selectionHiliteDisplay=False) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, polymeshes=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, nurbsSurfaces=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, subdivSurfaces=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, displayTextures=True) maya.cmds.modelEditor(snapshotPanel, camera=camera, edit=True, displayAppearance='smoothShaded') displayLights = maya.cmds.modelEditor(currentPanel, query=True, displayLights=True) maya.cmds.modelEditor(snapshotPanel, edit=True, displayLights=displayLights) maya.cmds.setParent('columnLayout') maya.cmds.button(label='Take Snapshot', width=width) rendererName = maya.cmds.modelEditor(currentPanel, query=True, rendererName=True) maya.cmds.modelEditor(snapshotPanel, edit=True, rendererName=rendererName) maya.cmds.window(snapshotWindow, edit=True, width=width, height=height + 25) maya.cmds.showWindow(snapshotWindow) try: path = playblast(path, snapshotPanel, start=start, end=end, frame=frame, width=width, height=height) finally: cmd = '\nimport maya.cmds;\nif maya.cmds.window("{window}", exists=True):\n maya.cmds.deleteUI("{window}", window=True)\n' cmd = cmd.format(window=snapshotWindow) maya.cmds.evalDeferred(cmd) return path