예제 #1
0
def check():
    """Makes sure everything is running right"""
    print("SYSTEM CHECK FOR {0}".format(mnpr_info.prototype))
    # check viewport
    viewport = lib.getActiveModelPanel()
    cmds.modelEditor(viewport, dtx=True, e=True)  # display textures

    # plugin needs to be loaded
    mnpr_info.loadRenderer()

    # 3rd party plugins must be loaded
    cmds.loadPlugin('shaderFXPlugin', quiet=True)
    if cmds.about(nt=True, q=True):
        cmds.loadPlugin(
            'dx11Shader',
            quiet=True)  # deprecated (only shadeFXPlugin in the future)
    cmds.loadPlugin(
        'glslShader',
        quiet=True)  # deprecated (only shaderFXPlugin in the future)

    # viewport renderer must be set
    mel.eval("setRendererAndOverrideInModelPanel vp2Renderer {0} {1};".format(
        mnpr_info.prototype, viewport))

    # modify color of heads up display
    cmds.displayColor("headsUpDisplayLabels", 2, dormant=True)
    cmds.displayColor("headsUpDisplayValues", 2, dormant=True)

    # make sure a config node exists
    if not cmds.objExists(mnpr_info.configNode):
        selected = cmds.ls(sl=True, l=True)
        selectConfig()
        cmds.select(selected, r=True)

    lib.printInfo("-> SYSTEM CHECK SUCCESSFUL")
예제 #2
0
    def applyColour(self):
        """ Return selected colour.
		"""
        self.index = mc.colorIndexSliderGrp("colour", q=1, value=True) - 1
        print(self.index)
        mc.displayColor('headsUpDisplayLabels', self.index, dormant=True)
        mc.displayColor('headsUpDisplayValues', self.index, dormant=True)
예제 #3
0
 def show(self, *args):
     if not self.__camera:
         self.__camera = mc.lookThru(q=1)
     # ----clear old huds---- #
     self.clear()
     # ----look through current camera ----#
     mc.lookThru(self.__camera)
     # ----set hud color ---- #
     mc.displayColor("headsUpDisplayLabels",
                     self.__hud_color["label_color"])
     mc.displayColor("headsUpDisplayValues",
                     self.__hud_color["value_color"])
     # ----create huds---- #
     for hud in self.__huds:
         label = self.__hud_dict[hud]["label"]
         section = self.__hud_dict[hud]["section"]
         block = mc.headsUpDisplay(nextFreeBlock=section)
         labelWidth = self.__hud_dict[hud]["labelWidth"]
         # event = self.__hud_dict[hud]["event"]
         labelFontSize = self.__hud_dict[hud]["labelFontSize"]
         dataFontSize = self.__hud_dict[hud]["dataFontSize"]
         blockSize = self.__hud_dict[hud]["blockSize"]
         command = self.__hud_dict[hud]["command"].format(
             camera=self.__camera)
         mc.headsUpDisplay(hud,
                           label=label,
                           section=section,
                           block=block,
                           labelWidth=labelWidth,
                           labelFontSize=labelFontSize,
                           dataFontSize=dataFontSize,
                           blockSize=blockSize,
                           attachToRefresh=True,
                           command=command)
예제 #4
0
def setCustomColors():
    """
    set the custom maya environment color scheme
    """
    
    # outliner
    cmds.displayRGBColor('outlinerInvisibleColor', 0.943999, 0.233173, 0.233173)
    """
    # background
    cmds.displayRGBColor('background', 0.6, 0.6, 0.6)
    cmds.displayRGBColor('backgroundBottom', 0.3, 0.3, 0.3)
    cmds.displayRGBColor('backgroundTop', 0.025, 0.025, 0.025)
    # meshes
    cmds.displayRGBColor('lead', 0.4, 0.4, 0.4, create=True)
    cmds.displayColor('hilite', 2, active=True)
    cmds.displayColor('hiliteComponent', 1, active=True)
    cmds.displayColor('lead', 3, active=True)
    cmds.displayColor('polymesh', 3, active=True)
    cmds.displayColor('polymesh', 2, dormant=True)
    """
    # default background
    cmds.displayRGBColor('background', 0.63099998235702515, 0.63099998235702515, 0.63099998235702515)
    cmds.displayRGBColor('backgroundBottom', 0.052000001072883606, 0.052000001072883606, 0.052000001072883606)
    cmds.displayRGBColor('backgroundTop', 0.5350000262260437, 0.61699998378753662, 0.70200002193450928)

    # default meshes
    cmds.displayRGBColor('lead', 0.4, 0.4, 0.4, create=True)
    cmds.displayColor('hilite', 18, active=True)
    cmds.displayColor('hiliteComponent', 9, active=True)
    cmds.displayColor('lead', 19, active=True)
    cmds.displayColor('polymesh', 16, active=True)
    cmds.displayColor('polymesh', 5, dormant=True)
예제 #5
0
def setCustomColors():
    """
    set custom maya environment color scheme
    """
    
    # script editor
    cmds.displayRGBColor('syntaxKeywords', 0.14, 0.9, 0.14)
    cmds.displayRGBColor('syntaxText', 0.84, 0.84, 0.84)
    cmds.displayRGBColor('syntaxStrings', 0.09, 0.4, 0.1)
    cmds.displayRGBColor('syntaxComments', 0.45, 0.45, 0.45)
    cmds.displayRGBColor('syntaxCommands', 0.75, 0.75, 0.27)
    cmds.displayRGBColor('syntaxBackground', 0.15, 0.15, 0.15)
    
    # background
    cmds.displayRGBColor('background', 0.6, 0.6, 0.6)
    cmds.displayRGBColor('backgroundBottom', 0.3, 0.3, 0.3)
    cmds.displayRGBColor('backgroundTop', 0.025, 0.025, 0.025)

    # meshes
    cmds.displayRGBColor('lead', 0.4, 0.4, 0.4, create=True)
    cmds.displayColor('hilite', 2, active=True)
    cmds.displayColor('hiliteComponent', 1, active=True)
    cmds.displayColor('lead', 3, active=True)
    cmds.displayColor('polymesh', 3, active=True)
    cmds.displayColor('polymesh', 2, dormant=True)
예제 #6
0
def setDefaultColors():
    """
    set the default maya environment color scheme
    """

    # script editor
    cmds.displayRGBColor('syntaxKeywords', 0.0, 1.0, 0.0)
    cmds.displayRGBColor('syntaxText', 0.78431373834609985, 0.78431373834609985, 0.78431373834609985)
    cmds.displayRGBColor('syntaxStrings', 1.0, 1.0, 0.0)
    cmds.displayRGBColor('syntaxComments', 1.0, 0.0, 0.0)
    cmds.displayRGBColor('syntaxCommands', 0.0, 1.0, 1.0)
    cmds.displayRGBColor('syntaxBackground', 0.16470588743686676, 0.16470588743686676, 0.16470588743686676)

    # background
    cmds.displayRGBColor('background', 0.63099998235702515, 0.63099998235702515, 0.63099998235702515)
    cmds.displayRGBColor('backgroundBottom', 0.052000001072883606, 0.052000001072883606, 0.052000001072883606)
    cmds.displayRGBColor('backgroundTop', 0.5350000262260437, 0.61699998378753662, 0.70200002193450928)

    # meshes
    cmds.displayRGBColor('lead', 0.40000000596046448, 0.40000000596046448, 0.40000000596046448, create=True)
    cmds.displayColor('hilite', 18, active=True)
    cmds.displayColor('hiliteComponent', 9, active=True)
    cmds.displayColor('lead', 19, active=True)
    cmds.displayColor('polymesh', 16, active=True)
    cmds.displayColor('polymesh', 5, dormant=True)
예제 #7
0
    def restoreSettings(self):
        '''
        restore all UI settings
        '''
        cmds.autoKeyframe(state=self.dataStore['autoKey'])

        # timeline management
        cmds.currentTime(self.dataStore['currentTime'])
        cmds.playbackOptions(min=self.dataStore['minTime'])
        cmds.playbackOptions(max=self.dataStore['maxTime'])
        cmds.playbackOptions(ast=self.dataStore['startTime'])
        cmds.playbackOptions(aet=self.dataStore['endTime'])
        cmds.playbackOptions(ps=self.dataStore['playSpeed'])
        cmds.playbackOptions(loop=self.dataStore['playLoop'])

        # unit management
        cmds.currentUnit(time=self.dataStore['timeUnit'])
        cmds.currentUnit(linear=self.dataStore['sceneUnits'])
        if not cmds.upAxis(axis=True, q=True) == self.dataStore['upAxis']:
            cmds.upAxis(axis=self.dataStore['upAxis'])

        log.debug('Restored PlayBack / Timeline setup')

        # viewport colors
        cmds.displayPref(displayGradient=self.dataStore['displayGradient'])
        cmds.displayRGBColor(resetToSaved=True)

        # objects colors
        cmds.displayColor("curve", self.dataStore['curvecolor'], dormant=True)

        # panel management
        for panel, data in self.dataStore['panelStore'].items():
            try:
                cmdString = data['settings'].replace('$editorName', panel)
                mel.eval(cmdString)
                log.debug("Restored Panel Settings Data >> %s" % panel)
                mel.eval('lookThroughModelPanel("%s","%s")' % (data['activeCam'], panel))
                log.debug("Restored Panel Active Camera Data >> %s >> cam : %s" % (panel, data['activeCam']))
            except:
                log.debug("Failed to fully Restore ActiveCamera Data >> %s >> cam : %s" % (panel, data['activeCam']))

        # camera management
        for cam, settings in self.dataStore['cameraTransforms'].items():
            try:
                cmds.setAttr('%s.translate' % cam, settings[0][0][0], settings[0][0][1], settings[0][0][2])
                cmds.setAttr('%s.rotate' % cam, settings[1][0][0], settings[1][0][1], settings[1][0][2])
                cmds.setAttr('%s.scale' % cam, settings[2][0][0], settings[2][0][1], settings[2][0][2])
                log.debug('Restored Default Camera Transform Data : % s' % cam)
            except:
                log.debug("Failed to fully Restore Default Camera Transform Data : % s" % cam)

        # sound management
        if self.dataStore['displaySound']:
            cmds.timeControl(self.gPlayBackSlider, e=True, ds=1, sound=self.dataStore['activeSound'])
            log.debug('Restored Audio setup')
        else:
            cmds.timeControl(self.gPlayBackSlider, e=True, ds=0)
        log.debug('Scene Restored fully')
        return True
예제 #8
0
    def restoreSettings(self):
        '''
        restore all UI settings
        '''
        cmds.autoKeyframe(state=self.dataStore['autoKey'])

        # timeline management
        cmds.currentTime(self.dataStore['currentTime'])
        cmds.playbackOptions(min=self.dataStore['minTime'])
        cmds.playbackOptions(max=self.dataStore['maxTime'])
        cmds.playbackOptions(ast=self.dataStore['startTime'])
        cmds.playbackOptions(aet=self.dataStore['endTime'])
        cmds.playbackOptions(ps=self.dataStore['playSpeed'])
        cmds.playbackOptions(loop=self.dataStore['playLoop'])

        # unit management
        cmds.currentUnit(time=self.dataStore['timeUnit'])
        cmds.currentUnit(linear=self.dataStore['sceneUnits'])
        if not cmds.upAxis(axis=True, q=True) == self.dataStore['upAxis']:
            cmds.upAxis(axis=self.dataStore['upAxis'])

        log.debug('Restored PlayBack / Timeline setup')

        # viewport colors
        cmds.displayPref(displayGradient=self.dataStore['displayGradient'])
        cmds.displayRGBColor(resetToSaved=True)

        # objects colors
        cmds.displayColor("curve", self.dataStore['curvecolor'], dormant=True)

        # panel management
        for panel, data in self.dataStore['panelStore'].items():
            try:
                cmdString = data['settings'].replace('$editorName', panel)
                mel.eval(cmdString)
                log.debug("Restored Panel Settings Data >> %s" % panel)
                mel.eval('lookThroughModelPanel("%s","%s")' % (data['activeCam'], panel))
                log.debug("Restored Panel Active Camera Data >> %s >> cam : %s" % (panel, data['activeCam']))
            except:
                log.debug("Failed to fully Restore ActiveCamera Data >> %s >> cam : %s" % (panel, data['activeCam']))

        # camera management
        for cam, settings in self.dataStore['cameraTransforms'].items():
            try:
                cmds.setAttr('%s.translate' % cam, settings[0][0][0], settings[0][0][1], settings[0][0][2])
                cmds.setAttr('%s.rotate' % cam, settings[1][0][0], settings[1][0][1], settings[1][0][2])
                cmds.setAttr('%s.scale' % cam, settings[2][0][0], settings[2][0][1], settings[2][0][2])
                log.debug('Restored Default Camera Transform Data : % s' % cam)
            except:
                log.debug("Failed to fully Restore Default Camera Transform Data : % s" % cam)

        # sound management
        if self.dataStore['displaySound']:
            cmds.timeControl(self.gPlayBackSlider, e=True, ds=1, sound=self.dataStore['activeSound'])
            log.debug('Restored Audio setup')
        else:
            cmds.timeControl(self.gPlayBackSlider, e=True, ds=0)
        log.debug('Scene Restored fully')
        return True
예제 #9
0
 def addHUD(self):
     self.removeHUD()
     cmds.displayColor('headsUpDisplayLabels', 18, dormant=True)
     cmds.headsUpDisplay('leftTopHUD', section=0, block=1, blockSize='medium', dataFontSize='large',
                    command=self.getShotInfo, atr=True)
     cmds.headsUpDisplay('rightTopHUD', section=4, block=1, blockSize='medium', dataFontSize='large',
                    command=self.getDate, atr=True)
     cmds.headsUpDisplay('rightBottomHUD', section=9, block=1, blockSize='medium', dataFontSize='large',
                    command=self.getFrame, atr=True)
예제 #10
0
	def setGridRugbyBugsDefault():
		#set correct grid units and display settings
		cmds.grid(spacing = 5, divisions = 5, size = 10)
		cmds.displayColor( 'gridHighlight', 12, dormant=True )
		cmds.displayColor( 'grid', 3, dormant=True )
		#Turn grid on by default
		gridState = cmds.grid( toggle=True, q=True )
		if not(gridState): cmds.grid( toggle = True )
		
		#Print to console instead of script editor
		sys.__stdout__.write('Successfully set Rugby Bugs standard grid deferred\n')
예제 #11
0
    def set_grid_default():

        #set correct grid units and display settings
        cmds.grid(spacing=5, divisions=5, size=10)
        cmds.displayColor('gridHighlight', 12, dormant=True)
        cmds.displayColor('grid', 3, dormant=True)

        #Turn grid on by default
        gridState = cmds.grid(toggle=True, q=True)
        if not (gridState): cmds.grid(toggle=True)

        #Print to console instead of script editor
        sys.__stdout__.write('Successfully set standard grid deferred\n')
        #Dividerline
        sys.__stdout__.write(DIVIDERLINE)
예제 #12
0
    def storeSettings(self):
        '''
        main work function, store all UI settings
        '''
        self.dataStore['autoKey'] = cmds.autoKeyframe(query=True, state=True)

        # timeline management
        self.dataStore['currentTime'] = cmds.currentTime(q=True)
        self.dataStore['minTime'] = cmds.playbackOptions(q=True, min=True)
        self.dataStore['maxTime'] = cmds.playbackOptions(q=True, max=True)
        self.dataStore['startTime'] = cmds.playbackOptions(q=True, ast=True)
        self.dataStore['endTime'] = cmds.playbackOptions(q=True, aet=True)
        self.dataStore['playSpeed'] = cmds.playbackOptions(query=True, playbackSpeed=True)
        self.dataStore['playLoop'] = cmds.playbackOptions(query=True, loop=True)

        # unit management
        self.dataStore['timeUnit'] = cmds.currentUnit(q=True, fullName=True, time=True)
        self.dataStore['sceneUnits'] = cmds.currentUnit(q=True, fullName=True, linear=True)
        self.dataStore['upAxis'] = cmds.upAxis(q=True, axis=True)

        # viewport colors
        self.dataStore['displayGradient'] = cmds.displayPref(q=True, displayGradient=True)

        # objects colors
        self.dataStore['curvecolor'] = cmds.displayColor("curve", q=True, dormant=True)

        # panel management
        self.dataStore['panelStore'] = {}
        for panel in ['modelPanel1', 'modelPanel2', 'modelPanel3', 'modelPanel4']:
            if not cmds.modelPanel(panel, q=True, exists=True):
                continue
            self.dataStore['panelStore'][panel] = {}
            self.dataStore['panelStore'][panel]['settings'] = cmds.modelEditor(panel, q=True, sts=True)
            activeCam = cmds.modelPanel(panel, q=True, camera=True)
            if not cmds.nodeType(activeCam) == 'camera':
                activeCam = cmds.listRelatives(activeCam, f=True)[0]
            self.dataStore['panelStore'][panel]['activeCam'] = activeCam

        # camera management
        # TODO : store the camera field of view etc also
        self.dataStore['cameraTransforms'] = {}
        for cam in ['persp', 'top', 'side', 'front']:
            try:
                self.dataStore['cameraTransforms'][cam] = [cmds.getAttr('%s.translate' % cam),
                                                     cmds.getAttr('%s.rotate' % cam),
                                                     cmds.getAttr('%s.scale' % cam)]
            except:
                log.debug("Camera doesn't exists : %s" % cam)

        # sound management
        self.dataStore['activeSound'] = cmds.timeControl(self.gPlayBackSlider, q=True, s=1)
        self.dataStore['displaySound'] = cmds.timeControl(self.gPlayBackSlider, q=True, ds=1)
예제 #13
0
    def storeSettings(self):
        '''
        main work function, store all UI settings
        '''
        self.dataStore['autoKey'] = cmds.autoKeyframe(query=True, state=True)

        # timeline management
        self.dataStore['currentTime'] = cmds.currentTime(q=True)
        self.dataStore['minTime'] = cmds.playbackOptions(q=True, min=True)
        self.dataStore['maxTime'] = cmds.playbackOptions(q=True, max=True)
        self.dataStore['startTime'] = cmds.playbackOptions(q=True, ast=True)
        self.dataStore['endTime'] = cmds.playbackOptions(q=True, aet=True)
        self.dataStore['playSpeed'] = cmds.playbackOptions(query=True, playbackSpeed=True)
        self.dataStore['playLoop'] = cmds.playbackOptions(query=True, loop=True)

        # unit management
        self.dataStore['timeUnit'] = cmds.currentUnit(q=True, fullName=True, time=True)
        self.dataStore['sceneUnits'] = cmds.currentUnit(q=True, fullName=True, linear=True)
        self.dataStore['upAxis'] = cmds.upAxis(q=True, axis=True)

        # viewport colors
        self.dataStore['displayGradient'] = cmds.displayPref(q=True, displayGradient=True)

        # objects colors
        self.dataStore['curvecolor'] = cmds.displayColor("curve", q=True, dormant=True)

        # panel management
        self.dataStore['panelStore'] = {}
        for panel in ['modelPanel1', 'modelPanel2', 'modelPanel3', 'modelPanel4']:
            if not cmds.modelPanel(panel, q=True, exists=True):
                continue
            self.dataStore['panelStore'][panel] = {}
            self.dataStore['panelStore'][panel]['settings'] = cmds.modelEditor(panel, q=True, sts=True)
            activeCam = cmds.modelPanel(panel, q=True, camera=True)
            if not cmds.nodeType(activeCam) == 'camera':
                activeCam = cmds.listRelatives(activeCam, f=True)[0]
            self.dataStore['panelStore'][panel]['activeCam'] = activeCam

        # camera management
        # TODO : store the camera field of view etc also
        self.dataStore['cameraTransforms'] = {}
        for cam in ['persp', 'top', 'side', 'front']:
            try:
                self.dataStore['cameraTransforms'][cam] = [cmds.getAttr('%s.translate' % cam),
                                                     cmds.getAttr('%s.rotate' % cam),
                                                     cmds.getAttr('%s.scale' % cam)]
            except:
                log.debug("Camera doesn't exists : %s" % cam)

        # sound management
        self.dataStore['activeSound'] = cmds.timeControl(self.gPlayBackSlider, q=True, s=1)
        self.dataStore['displaySound'] = cmds.timeControl(self.gPlayBackSlider, q=True, ds=1)
예제 #14
0
 def addHUD(self):
     self.removeHUD()
     cmds.displayColor('headsUpDisplayLabels', 18, dormant=True)
     cmds.headsUpDisplay('leftTopHUD',
                         section=0,
                         block=1,
                         blockSize='medium',
                         dataFontSize='large',
                         command=self.getShotInfo,
                         atr=True)
     cmds.headsUpDisplay('rightTopHUD',
                         section=4,
                         block=1,
                         blockSize='medium',
                         dataFontSize='large',
                         command=self.getDate,
                         atr=True)
     cmds.headsUpDisplay('rightBottomHUD',
                         section=9,
                         block=1,
                         blockSize='medium',
                         dataFontSize='large',
                         command=self.getFrame,
                         atr=True)
예제 #15
0
    def UI(self, index=None):
        """ Create UI.
		"""
        if index is None:
            self.index = mc.displayColor('headsUpDisplayLabels', q=1) + 1
            # mc.displayColor('headsUpDisplayValues', query=True)
        else:
            self.index = index

        # Check if UI window already exists
        if mc.window(self.winName, exists=True):
            mc.deleteUI(self.winName)

        # Create window
        mc.window(self.winName,
                  title=self.winTitle,
                  sizeable=True,
                  menuBar=True,
                  menuBarVisible=True)

        # Create menu bar
        # mc.menu(label="Edit", tearOff=False)
        # mc.menuItem(label="Reset Settings", command="")
        # mc.menu(label="Help", tearOff=False)
        # mc.menuItem(label="About...", command=lambda *args: self.aboutUI())

        # Create controls
        #setUITemplate -pushTemplate mjbToolsTemplate;
        mc.columnLayout("windowRoot")
        self.colourPickerUI("indexColourRollout", "windowRoot")

        mc.separator(height=8, style="none")
        mc.rowLayout(numberOfColumns=2)
        mc.button(width=198,
                  height=28,
                  label="Apply",
                  command=lambda *args: self.applyColourAndClose())
        mc.button(width=198,
                  height=28,
                  label="Close",
                  command=lambda *args: mc.deleteUI(self.winName))
        #setUITemplate -popTemplate;

        mc.showWindow(self.winName)
        return self.index
예제 #16
0
 def _changeGrid(self, gSize, gSpacing, gDivisions, gcGridA, gcGridHl,
                 gcGrid, fClipping, nClipping, trans, *args):
     """
     Sets several grid settings
     Color: gridAxis, gridHighlight, grid
     Distance: nearClipPlan, farClipPlan
     Camera: X,Y,Z
     """
     cmds.grid(size=gSize, spacing=gSpacing, divisions=gDivisions)
     cmds.displayColor('gridAxis', gcGridA, q=True, dormant=True)
     cmds.displayColor('gridHighlight', gcGridHl, q=True, dormant=True)
     cmds.displayColor('grid', gcGrid, q=True, dormant=True)
     cmds.setAttr('perspShape.farClipPlane', fClipping)
     cmds.setAttr('perspShape.nearClipPlane', nClipping)
     cmds.setAttr('top.translateY', trans)
     cmds.setAttr('front.translateZ', trans)
     cmds.setAttr('side.translateX', trans)
     cmds.viewSet(home=True, animate=True)
예제 #17
0
def setupPrefs():
    #set the current options on load of maya (incase someone manually changed them it their settings)
    pm.playbackOptions(min=1, max=120)
    pm.currentTime(1)
    if 'FS' in os.environ and 'FE' in os.environ:
        first = os.environ['FS']
        last = os.environ['FE']
        fps = os.environ['FPS']
        fpsPreset = getFPSpreset(fps)
        mc.currentUnit(time=fpsPreset)
        if not first == '1' and not last == '2':
            pm.playbackOptions(minTime=first, maxTime=last, animationStartTime=first,
                               animationEndTime=last)
            pm.currentTime(first)

    '''pm.grid(size=1000, spacing=100, divisions=10)
    pm.optionVar (fv=("playbackMax",120))
    pm.optionVar (fv=("playbackMaxDefault",120))
    pm.optionVar (fv=("playbackMaxRange",120))
    pm.optionVar (fv=("playbackMaxRangeDefault",120))
    pm.optionVar (fv=("playbackMin",1))
    pm.optionVar (fv=("playbackMinDefault",1))
    pm.optionVar (fv=("playbackMinRange",1))
    pm.optionVar (fv=("playbackMinRangeDefault",1))'''

    #setting the grid settings
    pm.optionVar (fv=("gridDivisions",10))
    pm.optionVar (fv=("gridSize",1000))
    pm.optionVar (fv=("gridSpacing",100))

    mc.displayColor('gridAxis', 2, dormant=True)
    mc.displayColor('gridHighlight', 1, dormant=True)
    mc.displayColor('grid', 3, dormant=True)

    #setting the units
    pm.optionVar (sv=("workingUnitLinear", "cm"))
    pm.optionVar (sv=("workingUnitLinearDefault", "cm"))
예제 #18
0
def changeGridSettings(set, s, sp, div, ncp, fcp, gac, ghc, gc, trans):
    cmds.displayColor('gridAxis', gac, c=True, dormant=True)
    cmds.displayColor('gridHighlight', ghc, c=True, dormant=True)
    cmds.displayColor('grid', gc, c=True, dormant=True)
    cmds.setAttr('perspShape.farClipPlane', fcp)
    cmds.setAttr('perspShape.nearClipPlane', ncp)
    cmds.setAttr('topShape.farClipPlane', fcp)
    cmds.setAttr('topShape.nearClipPlane', ncp)
    cmds.setAttr('sideShape.farClipPlane', fcp)
    cmds.setAttr('sideShape.nearClipPlane', ncp)
    cmds.setAttr('frontShape.farClipPlane', fcp)
    cmds.setAttr('frontShape.nearClipPlane', ncp)
    cmds.setAttr('top.translateY', trans)
    cmds.setAttr('front.translateZ', trans)
    cmds.setAttr('side.translateX', trans)

    # sets Unity grid settings
    if set == "unity":
        # shows unity division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=True)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets division text default
        cmds.intField('unityMultiplier', edit=True, value=100)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("Unity grid activated", "")
        mel.eval(
            "viewSet -animate `optionVar -query animateRollViewCompass` -home;"
        )
        mel.eval('currentUnit -linear "cm";')

    #sets UDK grid settings
    elif set == "udk":
        # shows udk division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=True)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets division text default
        cmds.intField('udkMultiplier', edit=True, value=16)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("UDK grid activated", "")
        mel.eval(
            "viewSet -animate `optionVar -query animateRollViewCompass` -home;"
        )
        mel.eval('currentUnit -linear "cm";')

    #sets CryEngine grid settings
    elif set == "cryengine":
        # shows cryengine division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=True)
        # sets division text default
        cmds.intField('cryengineMultiplier', edit=True, value=100)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("CryEngine grid activated", "")
        mel.eval(
            "viewSet -animate `optionVar -query animateRollViewCompass` -home;"
        )
        mel.eval('currentUnit -linear "cm";')

    #restores Maya grid settings
    elif set == "maya":
        # hides all division text and buttons
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("Maya grid restored", "")
        mel.eval(
            "viewSet -animate `optionVar -query animateRollViewCompass` -home;"
        )
        mel.eval('currentUnit -linear "cm";')
예제 #19
0
    def _localPlayblast(self):
        self.shotsToPlayblast = [item.text(0) for item in self.treeWidgetItems if item.checkState(0)]
        self.mySubShots = self._getSubShots()
        if self.mySubShots :
            for eachSubShotDic in self.mySubShots:##Process all the data for each shot now...
                ## Get the correct frame range from shotgun for the shot
                ##[{'type': 'Shot', 'id': 5737, 'name': 'eptst2_sh001'}, {'type': 'Shot', 'id': 5738, 'name': 'eptst2_sh002'}]
                if eachSubShotDic['name'] in self.shotsToPlayblast:
                    path = 'I:/bubblebathbay/layout_movs/'
                    episode = eachSubShotDic['name'].split('_')[0]
                    shots = self.entity['name']
                    lat = 'latest'
                    ver = 'version'
                    versionNumber = 001
                    fileName = '%sLayout.v%03d.mov' % (eachSubShotDic['name'].replace('_', ''), versionNumber)
                    movPathToLatest = os.path.join(path, episode, shots, lat, fileName)
                    movPathToVersion = os.path.join(path, episode, shots, ver, fileName)
                    while os.path.exists(movPathToVersion):
                        versionNumber += 1
                        if versionNumber < 10:
                            newFileName = '%sLayout.v%03d.mov' % (eachSubShotDic['name'].replace('_', ''), versionNumber)
                            movPathToVersion = os.path.join(path, episode, shots, ver, newFileName)
                        else:
                            newFileName = '%sLayout.v%02d.mov' % (eachSubShotDic['name'].replace('_', ''), versionNumber)
                            movPathToVersion = os.path.join(path, episode, shots, ver, newFileName)
                    else:
                        pass

                    if not os.path.exists(os.path.join(path, episode, shots, lat)):
                        os.makedirs(os.path.join(path, episode, shots, lat))
                    if not os.path.exists(os.path.join(path, episode, shots, ver)):
                        os.makedirs(os.path.join(path, episode, shots, ver))
                    ### Path to work review folder
                    ## self.baseTemplateMoviePath needs fields to create a final mov path.
#                     fields = {}
#                     fields['Sequence'] = eachSubShotDic['name'].split('_')[0]
#                     fields['Shot'] = eachSubShotDic['name']
#                     fields['Step'] = 'Blck'
#                     fields['name'] = str(eachSubShotDic['name'].split('_')[0] + eachSubShotDic['name'].split('_')[1] + 'Layout')
#                     fields['version'] = 1
#                     publish_movie_path = self.baseTemplateMoviePath.apply_fields(fields)
                    ## Verify existing versions
#                     while os.path.exists(publish_movie_path):
#                         fields['version'] += 1
#                         publish_movie_path = self.baseTemplateMoviePath.apply_fields(fields)
#                     else:
#                         pass

                    activePanel = cmds.getPanel(wf=1)
                    modelPanels = cmds.getPanel(type='modelPanel')
                    camShape = '%s_shotCamShape' % eachSubShotDic['name']
                    if activePanel in modelPanels:
                        modEditor = cmds.modelEditor(activePanel, e=1, cam=camShape, displayAppearance='smoothShaded', displayTextures=True)
                        cmds.modelEditor(activePanel, e=1, allObjects=0)
                        cmds.modelEditor(activePanel, e=1, polymeshes=1, ns=1, hud=1, ps=1, po=('gpuCacheDisplayFilter', 1))
                        mpShotFrameRange = shotFrameRange.FetchShotFrameRange()
                        mel.eval('setFocalLengthVisibility(on);')
                        mel.eval('setCurrentFrameVisibility(on);')
                        mel.eval('setCameraNamesVisibility(on);')
                        mel.eval('setSceneTimecodeVisibility(on);')
                        cmds.displayColor('headsUpDisplayLabels', 16)
                        cmds.displayColor('headsUpDisplayValues', 16)
                        getCameraStartFrame = mpShotFrameRange.fetchShotFrameRange_Fn(eachSubShotDic['name'])
                        cmds.setAttr("defaultResolution.width", 1280)
                        cmds.setAttr("defaultResolution.height", 720)
                        endFrame = getCameraStartFrame['mpEndFrame'] + 1
                        cmds.playblast(sound= eachSubShotDic['name'],
                                       filename=movPathToVersion,
                                       offScreen=1,
                                       widthHeight=[1280,720],
                                       quality=100, 
                                       startTime= getCameraStartFrame['mpStartFrame'],
                                       endTime= endFrame,
                                       format='qt',
                                       forceOverwrite = True,
                                       activeEditor = False,
                                       clearCache = True,
                                       combineSound = True,
                                       compression = 'h.264',
                                       framePadding = 4,
                                       options = False,
                                       sequenceTime = False,
                                       showOrnaments = True,
                                       viewer = True,
                                       percent=75
                                       )
                        shutil.copy2(movPathToVersion, movPathToLatest)
                    else:
                        QtGui.QMessageBox.information(None, "Aborted...", 'You must have active a current 3D viewport! \nRight click the viewport you wish to playblast from.')
                else:
                    pass
        else:
            cmds.warning('This shot has no valid subshots in shotgun to process!!!')
예제 #20
0
def sceneCleanup(silent = True):
    mc.displayColor('headsUpDisplayLabels', 16, dormant=True)
    namespaces = mc.namespaceInfo(lon = True)
    if "Suleiman00s_pr01" in namespaces:
        mc.namespace(ren = ("Suleiman00s_pr01", "Suleiman00p_pr01"), f = True)
    mayaShot = ppc.MayaShot()
    if not mayaShot.validShot:
        msgWin("Error", "Invalid Shot or Project", silent)
        return False
    epsq = mayaShot.epSqName
    shot = mayaShot.shName
    stereoCams = []
    mc.setAttr("defaultResolution.width", mayaShot.projInfo.resWidth)
    mc.setAttr("defaultResolution.height", mayaShot.projInfo.resHeight)
    mc.setAttr("defaultResolution.deviceAspectRatio", mayaShot.projInfo.aspectRatio)
    camPattern = "(ep|sq)[0-9]{3}sh[0-9]{3}([a-b]{1})?_camCt"
    camName = "%s%s_camCt" % (epsq, shot)
    scCams = mc.ls(type = "camera")
    renCams = []
    for cam in scCams:
        camTr = mc.listRelatives(cam, p = True)
        pMatch = re.search(camPattern, camTr[0])
        if pMatch:
            renCams.append(camTr[0])
    if not renCams:
        msgWin("Error", "Couldn't find a valid camera", silent)
        return False
    if len(renCams) > 1:
        msgWin("Error", "Too many cameras in the scene.\nPlease delete unwanted cameras", silent)
        return False
    if not renCams[0] == camName:
        mc.rename(renCams[0], camName)
    if mayaShot.projInfo.stereo:
        stereoCams = mc.listRelatives(camName, c = 1, typ = 'transform')
        for stCam in stereoCams:
            nodeTyp = mc.nodeType(stCam, i = True)
            if "constraint" in nodeTyp:
                continue
            if mc.getAttr(stCam + ".tx") < 0:
                mc.rename(stCam, camName.replace("_camCt", "_camLt"))
            else:
                mc.rename(stCam, camName.replace("_camCt", "_camRt"))
        camShape = "%sCenterCamShape" % camName
    else:
        camShape = "%sShape" % camName
    camShps = mc.listRelatives(camName, c = True, s = True)
    for shp in camShps:
        sMatch = re.search(camPattern, shp)
        if sMatch:
            mc.rename(shp, shp.replace(sMatch.group(0), camName))
        else:
            print "Unable to find correct name for %s" % shp
    camParent = mc.listRelatives(camName, p = True)
    if camParent:
        camParent = camParent[0]
    if not camParent in ["CAM", "Aim_camera", "Ctl_Camera", "camera_group"]:
        if not mc.objExists("CAM"):
            mc.group(n = "CAM", em = True)
        try:
            mc.parent(camName, "CAM")
        except:
            pass
    camTopGrp = mc.listRelatives("CAM", p = True)
    if not camTopGrp == "CAMERAS":
        if not mc.objExists("CAMERAS"):
            mc.group(n = "CAMERAS", em = True)
        try:
            mc.parent("CAM", "CAMERAS")
        except:
            pass
    huds = ["HUDShotName", "HUDUserName", "HUDfocalLength", "HUDFrameNo"]
    for hud in huds:
        if mc.headsUpDisplay(hud, ex = True):
            mc.headsUpDisplay(hud, rem = True)
    focLen = mc.getAttr("%s.focalLength" % camShape)
    mc.headsUpDisplay('HUDfocalLength', s = 5, b = 1, bs = 'small', l = 'focalLength: %s' % focLen, lfs = 'large')
    mc.headsUpDisplay('HUDShotName', s = 6, b = 1, bs = 'small', l = 'shot: %s%s' % (epsq, shot), lfs = 'large')
    #username = os.environ['USERNAME']
    #mc.headsUpDisplay('HUDUserName', s = 7, b = 1, bs = 'small', l = 'user: %s' % username, lfs = 'large')
    mc.headsUpDisplay('HUDFrameNo', s = 8, b = 1, bs = 'small', l = 'frame: ', lfs = 'large', c = 'import maya.cmds as mc; mc.currentTime(q = True)', atr = True)
    scnCameras = [camName]
    if stereoCams: scnCameras.extend(mc.listRelatives(camName, c = 1, typ = 'transform'))
    for scnCam in scnCameras:
        mc.camera(scnCam, e = 1, dfg = 0, dgm = 1, dr = 1, ovr = 1.1)
        if mayaShot.projInfo.stereo and scnCam.endswith("_camCt"):
            scnCam = scnCam + "CenterCam"
        mc.setAttr('%sShape.displayGateMaskOpacity' % scnCam, l = 0)
        mc.setAttr('%sShape.displayGateMaskOpacity' % scnCam, 1)
        mc.setAttr ('%sShape.displayGateMaskColor' % scnCam, l = 0)
        mc.setAttr ('%sShape.displayGateMaskColor' % scnCam, 0, 0, 0)
    if mc.objExists('hudFix_node'):
        mc.delete('hudFix_node')
    mayaShot.moveAssetsToGrps()
    shotFrames = mayaShot.frames
    mc.playbackOptions(min=101, max=100+int(shotFrames), ast=101, aet=100+int(shotFrames))
    om.MGlobal.displayInfo("Scene cleaned up.")
예제 #21
0
def changeGridSettings(set, s, sp, div, ncp, fcp, gac, ghc, gc, trans):
    cmds.displayColor('gridAxis', gac, c=True, dormant=True)
    cmds.displayColor('gridHighlight', ghc, c=True, dormant=True)
    cmds.displayColor('grid', gc, c=True, dormant=True)
    cmds.setAttr('perspShape.farClipPlane', fcp)
    cmds.setAttr('perspShape.nearClipPlane', ncp)
    cmds.setAttr('topShape.farClipPlane', fcp)
    cmds.setAttr('topShape.nearClipPlane', ncp)
    cmds.setAttr('sideShape.farClipPlane', fcp)
    cmds.setAttr('sideShape.nearClipPlane', ncp)
    cmds.setAttr('frontShape.farClipPlane', fcp)
    cmds.setAttr('frontShape.nearClipPlane', ncp)
    cmds.setAttr('top.translateY', trans)
    cmds.setAttr('front.translateZ', trans)
    cmds.setAttr('side.translateX', trans)

    # sets Unity grid settings
    if set == "unity":
        # shows unity division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=True)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets division text default
        cmds.intField('unityMultiplier', edit=True, value=100)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("Unity grid activated", "")
        mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;")
        mel.eval('currentUnit -linear "cm";')

    #sets UDK grid settings
    elif set == "udk":
        # shows udk division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=True)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets division text default
        cmds.intField('udkMultiplier', edit=True, value=16)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("UDK grid activated", "")
        mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;")
        mel.eval('currentUnit -linear "cm";')

    #sets CryEngine grid settings
    elif set == "cryengine":
        # shows cryengine division text and buttons, hides others
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=True)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=True)
        # sets division text default
        cmds.intField('cryengineMultiplier', edit=True, value=100)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("CryEngine grid activated", "")
        mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;")
        mel.eval('currentUnit -linear "cm";')

    #restores Maya grid settings
    elif set == "maya":
        # hides all division text and buttons
        cmds.rowColumnLayout('unityDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivUnits', edit=True, visible=False)
        cmds.rowColumnLayout('unityDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('udkDivButtons', edit=True, visible=False)
        cmds.rowColumnLayout('cryengineDivButtons', edit=True, visible=False)
        # sets grid, prints to console, sets camera, and sets Maya units to centimeters
        cmds.grid(size=s, spacing=sp, divisions=div)
        consolePrint("Maya grid restored", "")
        mel.eval("viewSet -animate `optionVar -query animateRollViewCompass` -home;")
        mel.eval('currentUnit -linear "cm";')
예제 #22
0
 def labelcolor(self):
     return cmds.displayColor("headsUpDisplayLabels", q = True)
예제 #23
0
    def _do_playblast(self):

        MODEL_EDITOR_PARAMS = {
            "activeView": True,
            "cameras": False,
            "controlVertices": False,
            "deformers": False,
            "dimensions": False,
            "displayAppearance": "smoothShaded",
            "displayLights": "default",
            "displayTextures": True,
            "dynamicConstraints": False,
            "fogging": False,
            "follicles": False,
            "grid": False,
            "handles": False,
            "headsUpDisplay": True,
            "hulls": False,
            "ignorePanZoom": False,
            "ikHandles": False,
            "imagePlane": True,
            "joints": False,
            "lights": False,
            "locators": False,
            "manipulators": False,
            "nurbsCurves": False,
            "nurbsSurfaces": True,
            "pivots": False,
            "planes": False,
            "selectionHiliteDisplay": False,
            "shadows": False,
            "sortTransparent": True,
            "strokes": True,
            "textures": True,
            "useDefaultMaterial": False,
            "wireframeOnShaded": False,
        }

        windowName = "review_blast"

        try:
            _current_panel = pm.getPanel(wf=True)
            if pm.modelEditor(_current_panel, q=True, fogging=True) == True:
                MODEL_EDITOR_PARAMS["fogging"] = True
        except:
            pass

        try:
            if pm.windowPref(windowName, exists=True):
                pm.windowPref(windowName, remove=True)
                pm.deleteUI(windowName)
        except:
            pass

        _window = pm.window(windowName,
                            titleBar=True,
                            iconify=True,
                            leftEdge=100,
                            topEdge=100,
                            width=800,
                            height=600,
                            sizeable=False)

        _layout = pm.formLayout()
        _editor = pm.modelEditor(**MODEL_EDITOR_PARAMS)

        pm.formLayout(_layout,
                      edit=True,
                      attachForm=((_editor, "left", 0), (_editor, "top", 0),
                                  (_editor, "right", 0), (_editor, "bottom",
                                                          0)))

        # Legacy viewport used
        try:
            mel.eval("setRendererInModelPanel ogsRenderer {};".format(_editor))
        except:
            cmds.confirmDialog(
                message=
                'You need to change your viewport as the legacy version',
                dismissString='No')

        # viewport 2.0 used
        # mel.eval( "setRendererInModelPanel \"vp2Renderer\" {};".format( _editor))

        pm.setFocus(_editor)
        pm.lookThru(_editor, self._shot_cam)

        cmds.refresh()

        _labelColor = cmds.displayColor('headsUpDisplayLabels',
                                        q=True,
                                        dormant=True)
        _labelValue = cmds.displayColor('headsUpDisplayValues',
                                        q=True,
                                        dormant=True)

        visibleHUDs = [
            f for f in pm.headsUpDisplay(listHeadsUpDisplays=True)
            if pm.headsUpDisplay(f, query=True, visible=True)
        ]
        map(lambda f: pm.headsUpDisplay(f, edit=True, visible=False),
            visibleHUDs)

        for h in pm.headsUpDisplay(listHeadsUpDisplays=True):
            if pm.headsUpDisplay(h, q=1, s=1) == 7:
                if pm.headsUpDisplay(h, q=1, b=1) == 5:
                    try:
                        pm.headsUpDisplay(h, rem=True)
                    except:
                        pass

        for h in pm.headsUpDisplay(listHeadsUpDisplays=True):
            if pm.headsUpDisplay(h, q=1, s=1) == 7:
                if pm.headsUpDisplay(h, q=1, b=1) == 6:
                    try:
                        pm.headsUpDisplay(h, rem=True)
                    except:
                        pass

        cmds.displayColor('headsUpDisplayValues', 17, dormant=True)
        cmds.displayColor('headsUpDisplayLabels', 16, dormant=True)

        def hudShot():
            _nameTemp = cmds.file(q=1, ns=1).split(".")[0]
            return _nameTemp.rsplit("_", 1)[0]

        def hudName():
            return getpass.getuser()

        pm.headsUpDisplay('HUDCurrentFrame',
                          edit=True,
                          visible=True,
                          labelFontSize="large",
                          dataFontSize="large",
                          section=5,
                          block=1)
        #cmds.headsUpDisplay('HUDA',s=7,b=6, blockAlignment='center', dataFontSize='large', command=hudShot)
        #cmds.headsUpDisplay('HUDB',s=7,b=5, blockAlignment='center', dataFontSize='large', label="Artist:", labelFontSize="large", command=hudName)

        pm.setFocus(_editor)

        #if pm.headsUpDisplay('HUDCurrentFrame', query=True, visible=False):
        #    print "works 111"
        #    pass
        #else:
        _mov_file = os.path.splitext(self._file)[0]
        # print _mov_file
        # __audios = pm.ls(type="audio")
        __audios = pm.ls(type="audio")

        if len(__audios) > 0:
            __audio = str(__audios[0])
        else:
            __audio = False

        # frame catching min, max, current
        _min_frame = pm.playbackOptions(q=1, min=1)
        _max_frame = pm.playbackOptions(q=1, max=1)
        _current_frame = pm.currentTime(q=1)
        pm.currentTime(_min_frame)

        ### playblast option ###
        # play_args = "playblast -format avfoundation -filename \"{}\" -sound \"{}\" -sequenceTime 0 -clearCache 1 -viewer 1 -forceOverwrite -showOrnaments 1 -offScreen -fp 4 -percent 100 -compression \"H.264\" -quality 70 -widthHeight {} {};".format( self._file, __audio, self.resolution_size[0], self.resolution_size[1])

        try:

            _temp_path, _temp_file = os.path.split(self._file)
            _temp_mov_path = _temp_path + "/.temp"

            _temp_file_01 = os.path.splitext(_temp_file)
            _temp_mov_file = _temp_file_01[0] + "_uncomp" + _temp_file_01[1]

            _full_temp_mov_file = os.path.join(_temp_mov_path, _temp_mov_file)

            print _full_temp_mov_file

            try:
                if not os.path.exists(_temp_mov_path):
                    os.makedirs(_temp_mov_path)

                if os.path.exists(_full_temp_mov_file):
                    os.remove(_full_temp_mov_file)
            except:
                raise

            ### making playblast
            play_args = "playblast -format qt -filename \"{}\" -sound \"{}\" -sequenceTime 0 -clearCache 1 -viewer 0 -showOrnaments 1 -compression \"H.264\" -offScreen -fp 4 -percent 100 -quality 100 -widthHeight {} {};".format(
                _full_temp_mov_file, __audio, self.resolution_size[0],
                self.resolution_size[1])
            mel.eval(play_args)
            pm.currentTime(_current_frame)

            sceneName = pm.sceneName()
            tk = sgtk.sgtk_from_path(sceneName)

            # get entity information
            _context = tk.context_from_path(sceneName)

            _date = datetime.date.today()
            _task = _context.step["name"]
            _shot_name = _context.entity["name"]
            _png_file = os.path.normpath(
                _temp_mov_path + "/" +
                _context.user["name"].translate(None, string.whitespace) +
                ".png")

            try:
                if not os.path.exists(_temp_mov_path):
                    os.makedirs(_temp_mov_path)

                if os.path.exists(_png_file):
                    os.remove(_png_file)
            except:
                raise

            ### write information on png file ###
            _copylight = "Copyright (C) {} JibJab Studios - All Rights Reserved".format(
                _date.year)
            _img = Image.new('RGBA', (1920, 1080), (0, 0, 0, 0))
            _slate_image = ImageDraw.Draw(_img)
            _type_shot_asset = ImageFont.truetype('/Library/Fonts/arial.ttf',
                                                  30)
            _type_copyright = ImageFont.truetype('/Library/Fonts/arial.ttf',
                                                 15)
            _type_task = ImageFont.truetype('/Library/Fonts/arial.ttf', 18)

            _slate_image.text((820, 1000),
                              _shot_name,
                              font=_type_shot_asset,
                              fill=(255, 255, 255, 128))
            _slate_image.text((780, 1060),
                              _copylight,
                              font=_type_copyright,
                              fill=(255, 255, 255, 128))
            _slate_image.text((910, 1035),
                              "Task : {}".format(_task),
                              font=_type_task,
                              fill=(255, 255, 255, 128))
            # _slate_image.text((1610, 1060), _review_file, font=_type_copyright, fill=(255,255,255,80))

            _img.save(_png_file, 'PNG')

            ### convert uncomppresed file to h.264
            #t = os.system("/Volumes/public/StoryBots/production/series/ask_the_storybots/03_shared_assets/01_cg/05_maya_tools/pipeline/module/ffmpeg/ffmpeg -y -i " + _full_temp_mov_file + " -vcodec libx264 -pix_fmt yuv420p -preset slower -crf 0 -vf eq=brightness=0.04 -g 1 -acodec copy " + self._file)
            t = os.system(
                "/Volumes/public/StoryBots/production/series/ask_the_storybots/03_shared_assets/01_cg/05_maya_tools/pipeline/module/ffmpeg/ffmpeg -y -i "
                + _full_temp_mov_file + " -i " + _png_file +
                " -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 22 -filter_complex \"overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2\" -g 0 -acodec copy "
                + self._file)
            ######################################
            #### This is RV open with mov file ###
            ######################################

            _mov_path_RV, _mov_file_RV = os.path.split(self._file)
            os.chdir(_mov_path_RV)
            subprocess.Popen(self._RV_path + _mov_file_RV, shell=True)

            if os.path.exists(_full_temp_mov_file):
                os.remove(_full_temp_mov_file)

            if os.path.exists(_png_file):
                os.remove(_png_file)

        except:
            pm.confirmDialog(
                title="Playblast Error",
                message=
                "Close your RV or deselect the file.\nYour file is being used from other application",
                defaultButton="Yes")
            raise

        # playblast  -format avfoundation -sound "ATS_301_sq020_020" -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -offScreen  -fp 4 -percent 80 -compression "H.264" -quality 70 -widthHeight 1920 1080;
        #pm.showWindow( _window )
        pm.headsUpDisplay('HUDCurrentFrame',
                          edit=True,
                          visible=False,
                          section=5,
                          block=1)
        # cmds.headsUpDisplay( 'HUDA', rem=True )
        # cmds.headsUpDisplay( 'HUDB', rem=True )
        # delete playblast window
        pm.deleteUI(_window)
        # revive HOD modes

        cmds.displayColor('headsUpDisplayValues', _labelColor, dormant=True)
        cmds.displayColor('headsUpDisplayLabels', _labelValue, dormant=True)
        map(lambda f: pm.headsUpDisplay(f, edit=True, visible=True),
            visibleHUDs)
예제 #24
0
 def valuecolor(self):
     return cmds.displayColor("headsUpDisplayValues", q = True)
예제 #25
0
 def labelcolor(self, num = 14):
     cmds.displayColor("headsUpDisplayLabels", num, dormant = True)
예제 #26
0
 def _localPlayblast(self):
     self.shotsToPlayblast = [
         item.text(0) for item in self.treeWidgetItems if item.checkState(0)
     ]
     self.mySubShots = self._getSubShots()
     if self.mySubShots:
         for eachSubShotDic in self.mySubShots:  ##Process all the data for each shot now...
             ## Get the correct frame range from shotgun for the shot
             ##[{'type': 'Shot', 'id': 5737, 'name': 'eptst2_sh001'}, {'type': 'Shot', 'id': 5738, 'name': 'eptst2_sh002'}]
             if eachSubShotDic['name'] in self.shotsToPlayblast:
                 path = 'I:/lsapipeline/layout_movs/'
                 episode = eachSubShotDic['name'].split('_')[0]
                 shots = self.entity['name']
                 lat = 'latest'
                 ver = 'version'
                 versionNumber = 001
                 fileName = '%sLayout.v%03d.mov' % (
                     eachSubShotDic['name'].replace('_', ''), versionNumber)
                 movPathToLatest = os.path.join(path, episode, shots, lat,
                                                fileName)
                 movPathToVersion = os.path.join(path, episode, shots, ver,
                                                 fileName)
                 while os.path.exists(movPathToVersion):
                     versionNumber += 1
                     if versionNumber < 10:
                         newFileName = '%sLayout.v%03d.mov' % (
                             eachSubShotDic['name'].replace(
                                 '_', ''), versionNumber)
                         movPathToVersion = os.path.join(
                             path, episode, shots, ver, newFileName)
                     else:
                         newFileName = '%sLayout.v%02d.mov' % (
                             eachSubShotDic['name'].replace(
                                 '_', ''), versionNumber)
                         movPathToVersion = os.path.join(
                             path, episode, shots, ver, newFileName)
                 else:
                     pass
                 if not os.path.exists(
                         os.path.join(path, episode, shots, lat)):
                     os.makedirs(os.path.join(path, episode, shots, lat))
                 if not os.path.exists(
                         os.path.join(path, episode, shots, ver)):
                     os.makedirs(os.path.join(path, episode, shots, ver))
                 activePanel = cmds.getPanel(wf=1)
                 modelPanels = cmds.getPanel(type='modelPanel')
                 camShape = '%s_shotCamShape' % eachSubShotDic['name']
                 if cmds.ls(eachSubShotDic['name'], type='audio'):
                     audio = cmds.ls(eachSubShotDic['name'], type='audio')
                 else:
                     audio = cmds.ls('%s*' % eachSubShotDic['name'],
                                     type="audio")
                 if activePanel in modelPanels:
                     if audio:
                         modEditor = cmds.modelEditor(
                             activePanel,
                             e=1,
                             cam=camShape,
                             displayAppearance='smoothShaded',
                             displayTextures=True)
                         cmds.modelEditor(activePanel, e=1, allObjects=0)
                         cmds.modelEditor(activePanel,
                                          e=1,
                                          polymeshes=1,
                                          ns=1,
                                          hud=1,
                                          ps=1,
                                          po=('gpuCacheDisplayFilter', 1))
                         mpShotFrameRange = shotFrameRange.FetchShotFrameRange(
                         )
                         mel.eval('setFocalLengthVisibility(on);')
                         mel.eval('setCurrentFrameVisibility(on);')
                         mel.eval('setCameraNamesVisibility(on);')
                         mel.eval('setSceneTimecodeVisibility(on);')
                         cmds.displayColor('headsUpDisplayLabels', 16)
                         cmds.displayColor('headsUpDisplayValues', 16)
                         getCameraStartFrame = mpShotFrameRange.fetchShotFrameRange_Fn(
                             eachSubShotDic['name'])
                         cmds.setAttr("defaultResolution.width", 1280)
                         cmds.setAttr("defaultResolution.height", 720)
                         endFrame = getCameraStartFrame['mpEndFrame'] + 1
                         cmds.playblast(
                             sound=audio[0],
                             filename=movPathToVersion,
                             offScreen=1,
                             widthHeight=[1280, 720],
                             quality=100,
                             startTime=getCameraStartFrame['mpStartFrame'],
                             endTime=endFrame,
                             format='qt',
                             forceOverwrite=True,
                             activeEditor=False,
                             clearCache=True,
                             combineSound=True,
                             compression='h.264',
                             framePadding=4,
                             options=False,
                             sequenceTime=False,
                             showOrnaments=True,
                             viewer=True,
                             percent=75)
                         shutil.copy2(movPathToVersion, movPathToLatest)
                     else:
                         QtGui.QMessageBox.information(
                             None, "Aborted...",
                             'Shot %s has no audio or naming is not proper for audio'
                             % eachSubShotDic['name'])
                 else:
                     QtGui.QMessageBox.information(
                         None, "Aborted...",
                         'You must have active a current 3D viewport! \nRight click the viewport you wish to playblast from.'
                     )
             else:
                 pass
     else:
         cmds.warning(
             'This shot has no valid subshots in shotgun to process!!!')
예제 #27
0
 def valuecolor(self, num = 16):
     cmds.displayColor("headsUpDisplayValues", num, dormant = True)
예제 #28
0
    def __check__(cls):
        sf = config.getConfig("startFrame")
        ast = int(cmds.playbackOptions(q=1, ast=1))
        aet = int(cmds.playbackOptions(q=1, aet=1))
        mint = int(cmds.playbackOptions(q=1, min=1))
        maxt = int(cmds.playbackOptions(q=1, max=1))
        if sf != ast:
            cmds.displayColor("headsUpDisplayLabels", 17)
            cmds.displayColor("headsUpDisplayValues", 16)
            return u"初始帧不是第%s帧" % sf

        if len(cmds.ls(type='audio')) > 1:
            cmds.displayColor("headsUpDisplayLabels", 17)
            cmds.displayColor("headsUpDisplayValues", 16)
            return u"存在多重音轨"

        if ast != mint or aet != maxt:
            cmds.displayColor("headsUpDisplayLabels", 17)
            cmds.displayColor("headsUpDisplayValues", 16)
            return u"时间轴未最大化"

        cmds.displayColor("headsUpDisplayLabels", 14)
        cmds.displayColor("headsUpDisplayValues", 16)
        return ""