def _applied_display_options(options):
    """Context manager for setting background color display options."""

    options = dict(DisplayOptions, **(options or {}))

    colors = ['background', 'backgroundTop', 'backgroundBottom']
    preferences = ['displayGradient']

    # Store current settings
    original = {}
    for color in colors:
        original[color] = cmds.displayRGBColor(color, query=True) or []

    for preference in preferences:
        original[preference] = cmds.displayPref(query=True,
                                                **{preference: True})

    # Apply settings
    for color in colors:
        value = options[color]
        cmds.displayRGBColor(color, *value)

    for preference in preferences:
        value = options[preference]
        cmds.displayPref(**{preference: value})

    try:
        yield

    finally:
        # Restore original settings
        for color in colors:
            cmds.displayRGBColor(color, *original[color])
        for preference in preferences:
            cmds.displayPref(**{preference: original[preference]})
Beispiel #2
0
def _applied_display_options(options):
    """Context manager for setting background color display options."""
    from maya import cmds

    options = options or DisplayOptions()

    colors = ['background', 'backgroundTop', 'backgroundBottom']
    prefs = ['displayGradient']

    # store current settings
    original = {}
    for clr in colors:
        original[clr] = cmds.displayRGBColor(clr, query=True)
    for pref in prefs:
        original[pref] = cmds.displayPref(query=True, **{pref: True})

    # apply settings of options
    for clr in colors:
        value = getattr(options, clr)
        cmds.displayRGBColor(clr, *value)
    for pref in prefs:
        value = getattr(options, pref)
        cmds.displayPref(**{pref: value})

    yield

    # restore original settings
    for clr in colors:
        cmds.displayRGBColor(clr, *original[clr])
    for pref in prefs:
        cmds.displayPref(**{pref: original[pref]})
def load():
    '''loads animation environment'''
    print "loading animation environment presets..."
    #set autoKey
    cmds.autoKeyframe( state=True )
    #set 24fps and playback on all viewports
    cmds.playbackOptions(ps=1.0, v='all')
    #set unlimited undo's
    cmds.undoInfo( state=True, infinity=True )
    #set manipulator sizes
    if lib.checkAboveVersion(2014):
        cmds.manipOptions( r=False, hs=55, ls=4, sph=1 )
    else:
        cmds.manipOptions( r=False, hs=55, ls=4 )
    #set framerate visibility
    mel.eval("setFrameRateVisibility(1);")
    #gimbal rotation
    cmds.manipRotateContext('Rotate', e=True, mode=2)
    #world translation
    cmds.manipMoveContext('Move', e=True, mode=2)
    #time slider height
    aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
    cmds.timeControl(aPlayBackSliderPython, h=45, e=True);
    #special tick color
    cmds.displayRGBColor("timeSliderTickDrawSpecial", 1,0.5,0)

    #check if hotkeys have been set
    if (cmds.hotkey( 't', ctl=True, query=True, name = True)== 'CharacterAnimationEditorNameCommand'):
        print "Hotkeys have been previously loaded"
    else:
        setHotkeys('default')

    print "ENVIRONMENT SET\n", #the comma forces output on the status line
Beispiel #4
0
def apply_view(panel, **options):
    """Apply options to panel"""

    camera = cmds.modelPanel(panel, camera=True, query=True)

    # Display options
    display_options = options.get('display_options', {})
    for key, value in display_options.items():
        if key in _DisplayOptionsRGB:
            cmds.displayRGBColor(key, *value)
        else:
            cmds.displayPref(**{key: value})

    # Camera options
    camera_options = options.get('camera_options', {})
    for key, value in camera_options.items():
        cmds.setAttr(f'{camera}.{key}', value)

    # Viewport options
    viewport_options = options.get('viewport_options', {})
    for key, value in viewport_options.items():
        cmds.modelEditor(panel, edit=True, **{key: value})

    viewport2_options = options.get('viewport2_options', {})
    for key, value in viewport2_options.items():
        attr = f'hardwareRenderingGlobals.{key}'
        cmds.setAttr(attr, value)
Beispiel #5
0
    def setDefaultConfig(self):

        #STATIC PREFS
        # tumble config
        #cmds.tumbleCtx( 'tumbleContext', edit=True, alternateContext=True, tumbleScale=1.0, localTumble=0, autoOrthoConstrain=False, orthoLock=False)
        cmds.tumbleCtx('tumbleContext',
                       edit=True,
                       alternateContext=True,
                       tumbleScale=1.0,
                       localTumble=0)
        cmds.dollyCtx('dollyContext',
                      edit=True,
                      alternateContext=True,
                      scale=1.0,
                      localDolly=True,
                      centerOfInterestDolly=False)
        #timeline ticks display
        G.playBackSliderPython = G.playBackSliderPython or mel.eval(
            '$aTools_playBackSliderPython=$gPlayBackSlider')
        cmds.timeControl(G.playBackSliderPython,
                         edit=True,
                         showKeys="mainChannelBox",
                         showKeysCombined=True,
                         animLayerFilterOptions="active")
        #tickDrawSpecial Color
        cmds.displayRGBColor('timeSliderTickDrawSpecial', 1, 1, .4)

        #CUSTOMIZABLE PREFS
        for loopPref in PREFS:
            name = loopPref["name"]
            self.setPref(name, True)
Beispiel #6
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)
Beispiel #7
0
def apply_view(panel, **options):
    """Apply options to panel"""

    camera = cmds.modelPanel(panel, camera=True, query=True)

    # Display options
    display_options = options.get("display_options", {})
    for key, value in display_options.iteritems():
        if key in _DisplayOptionsRGB:
            cmds.displayRGBColor(key, *value)
        else:
            cmds.displayPref(**{key: value})

    # Camera options
    camera_options = options.get("camera_options", {})
    for key, value in camera_options.iteritems():
        cmds.setAttr("{0}.{1}".format(camera, key), value)

    # Viewport options
    viewport_options = options.get("viewport_options", {})
    for key, value in viewport_options.iteritems():
        cmds.modelEditor(panel, edit=True, **{key: value})

    viewport2_options = options.get("viewport2_options", {})
    for key, value in viewport2_options.iteritems():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        cmds.setAttr(attr, value)
Beispiel #8
0
def _applied_display_options(options):
    """Context manager for setting background color display options."""

    options = options or DisplayOptions()

    colors = ['background', 'backgroundTop', 'backgroundBottom']
    preferences = ['displayGradient']

    # Store current settings
    original = {}
    for color in colors:
        original[color] = cmds.displayRGBColor(color, query=True) or []

    for preference in preferences:
        original[preference] = cmds.displayPref(query=True, **{preference: True})

    # Apply settings
    for color in colors:
        value = getattr(options, color)
        cmds.displayRGBColor(color, *value)

    for preference in preferences:
        value = getattr(options, preference)
        cmds.displayPref(**{preference: value})

    try:
        yield

    finally:
        # Restore original settings
        for color in colors:
            cmds.displayRGBColor(color, *original[color])
        for preference in preferences:
            cmds.displayPref(**{preference: original[preference]})
Beispiel #9
0
def silhouetteIt():
    global background_color, silhouette_flag, object_sgs
    print silhouette_flag
    print object_sgs
    print background_color
    shapes = cmds.ls(g=True, v=True)
    filtered_shapes = filter(lambda o: (cmds.nodeType(o) == "mesh"), shapes)
    for s in filtered_shapes:
        if (silhouette_flag):
            shape_sg = object_sgs[s]
            connectSGToObj(shape_sg, s)
        else:
            obj_sg = cmds.listConnections(s, type="shadingEngine")[0]
            object_sgs[s] = obj_sg
            if (not shaderNodeExists("silhouetteShader")):
                createSurfaceShader("silhouetteShader", "silhouetteShaderSG")
            connectSGToObj("silhouetteShaderSG", s)

    if (silhouette_flag):
        cmds.displayRGBColor("background", background_color[0],
                             background_color[1], background_color[2])
        silhouette_flag = False
    else:
        background_color = cmds.displayRGBColor("background", q=True)
        cmds.displayRGBColor("background", 1, 1, 1)
        silhouette_flag = True
    print silhouette_flag
Beispiel #10
0
def parse_active_view():
    """Parse active view for settings"""
    panel = cmds.getPanel(withFocus=True)
    assert "model" in panel, "No active viewport"
    camera = cmds.modelPanel(panel, query=True, camera=True)
    camera_shape = cmds.listRelatives(camera, shapes=True)[0]

    return {
        "camera": camera,
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "camera_options": type("CameraOptions", (object, CameraOptions,), {
            "displayFilmGate": cmds.getAttr(camera_shape + ".displayFilmGate"),
            "displayResolution": cmds.getAttr(camera_shape + ".displayResolution"),
            "displaySafeAction": cmds.getAttr(camera_shape + ".displaySafeAction"),
        }),
        "viewport_options": type("ViewportOptions", (object, ViewportOptions,), {
            "useDefaultMaterial": cmds.modelEditor(panel, query=True, useDefaultMaterial=True),
            "wireframeOnShaded": cmds.modelEditor(panel, query=True, wireframeOnShaded=True),
            "displayAppearance": cmds.modelEditor(panel, query=True, displayAppearance=True),
            "displayTextures": cmds.modelEditor(panel, query=True, displayTextures=True),
            "displayLights": cmds.modelEditor(panel, query=True, displayLights=True),
            "shadows": cmds.modelEditor(panel, query=True, shadows=True),
            "xray": cmds.modelEditor(panel, query=True, xray=True),
        }),
        "display_options": type("DisplayOptions", (object, DisplayOptions,), {
            "background": cmds.displayRGBColor('background', q=True),
            "backgroundTop": cmds.displayRGBColor('backgroundTop', q=True),
            "backgroundBottom": cmds.displayRGBColor('backgroundBottom', q=True),
            'displayGradient': cmds.displayPref(dgr=True, q=True),
        }),
    }
def apply_view(panel, **options):
    """Apply options to panel"""

    camera = cmds.modelPanel(panel, camera=True, query=True)

    # Display options
    display_options = options.get("display_options", {})
    for key, value in display_options.iteritems():
        if key in _DisplayOptionsRGB:
            cmds.displayRGBColor(key, *value)
        else:
            cmds.displayPref(**{key: value})

    # Camera options
    camera_options = options.get("camera_options", {})
    for key, value in camera_options.iteritems():
        cmds.setAttr("{0}.{1}".format(camera, key), value)

    # Viewport options
    viewport_options = options.get("viewport_options", {})
    for key, value in viewport_options.iteritems():
        cmds.modelEditor(panel, edit=True, **{key: value})

    viewport2_options = options.get("viewport2_options", {})
    for key, value in viewport2_options.iteritems():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        cmds.setAttr(attr, value)
Beispiel #12
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
Beispiel #13
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
Beispiel #14
0
def mhUpdateUserColor(udColorIndex):
    rgbValue = cmds.colorSliderButtonGrp('mhCustomColorButtonGrp%d' %
                                         udColorIndex,
                                         query=True,
                                         rgb=True)

    cmds.displayRGBColor('userDefined%d' % udColorIndex, rgbValue[0],
                         rgbValue[1], rgbValue[2])
Beispiel #15
0
def assignDefaultShader():

    global switch
    activeModel = cmds.getPanel(wf=True)
    cmds.modelEditor(activeModel, e=True, udm=0)
    cmds.displayRGBColor( 'background', 0.61, 0.61, 0.61 )
    cmds.setAttr('lambert1.color', 0.5, 0.5, 0.5, type="double3")
    cmds.setAttr('lambert1.diffuse', 0.5)
    for node in cmds.ls(sl=True):
        cmds.color() # assign default wireframes
    switch = 1
Beispiel #16
0
def active_view_snapshot(*args):
    capture.snap(clipboard=True,
                 display_options={
                     "displayGradient":
                     cmds.displayPref(query=True, displayGradient=True),
                     "background":
                     cmds.displayRGBColor("background", query=True),
                     "backgroundTop":
                     cmds.displayRGBColor("backgroundTop", query=True),
                     "backgroundBottom":
                     cmds.displayRGBColor("backgroundBottom", query=True),
                 })
Beispiel #17
0
def assignBlackShader():

    global switch
    activeModel = cmds.getPanel(wf=True)
    cmds.modelEditor(activeModel, e=True, udm=1)
    cmds.displayRGBColor( 'background', 0, 0, 0 )
    cmds.setAttr('lambert1.color', 0, 0, 0, type="double3")
    cmds.setAttr('lambert1.diffuse', 0)
    cmds.displayRGBColor('userDefined1', 1 ,1 ,1 )

    for node in cmds.ls(sl = True):
        cmds.color(ud = 1) # assign white wireframes
    switch = 1
Beispiel #18
0
def getUserDefinedColors(inType=1):
    """
    @param inType: Int. 1 is RGB. 2 is HSV.
    @return: List. User defined colors 1-8.
    """
    tempList = []
    for color in xrange(1, 9):
        userString = "userDefined{0}".format(color)
        if inType == 1:
            colorSetting = cmds.displayRGBColor(userString, query=True)
        elif inType == 2:
            colorSetting = cmds.displayRGBColor(userString, query=True, hueSaturationValue=True)
        tempList.append(colorSetting)
    return tempList
Beispiel #19
0
def parse_view(panel):
    """Parse the scene, panel and camera for their current settings

    Example:
        >>> parse_view("modelPanel1")

    Arguments:
        panel (str): Name of modelPanel

    """

    camera = cmds.modelPanel(panel, query=True, camera=True)

    # Display options
    display_options = {}
    for key in DisplayOptions:
        if key in _DisplayOptionsRGB:
            display_options[key] = cmds.displayRGBColor(key, query=True)
        else:
            display_options[key] = cmds.displayPref(query=True, **{key: True})

    # Camera options
    camera_options = {}
    for key in CameraOptions:
        camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))

    # Viewport options
    viewport_options = {}

    # capture plugin display filters first to ensure we never override
    # built-in arguments if ever possible a plugin has similarly named
    # plugin display filters (which it shouldn't!)
    plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
    for plugin in plugins:
        plugin = str(plugin)  # unicode->str for simplicity of the dict
        state = cmds.modelEditor(panel, query=True, queryPluginObjects=plugin)
        viewport_options[plugin] = state

    for key in ViewportOptions:
        viewport_options[key] = cmds.modelEditor(panel,
                                                 query=True,
                                                 **{key: True})

    viewport2_options = {}
    for key in Viewport2Options.keys():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        try:
            viewport2_options[key] = cmds.getAttr(attr)
        except ValueError:
            continue

    return {
        "camera": camera,
        "display_options": display_options,
        "camera_options": camera_options,
        "viewport_options": viewport_options,
        "viewport2_options": viewport2_options
    }
Beispiel #20
0
def parse_view(panel):
    """Parse the scene, panel and camera for their current settings

    Example:
        >>> parse_view("modelPanel1")

    Arguments:
        panel (str): Name of modelPanel

    """

    camera = cmds.modelPanel(panel, query=True, camera=True)

    # Display options
    display_options = {}
    for key in DisplayOptions:
        if key in _DisplayOptionsRGB:
            display_options[key] = cmds.displayRGBColor(key, query=True)
        else:
            display_options[key] = cmds.displayPref(query=True, **{key: True})

    # Camera options
    camera_options = {}
    for key in CameraOptions:
        camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))

    # Viewport options
    viewport_options = {}

    # capture plugin display filters first to ensure we never override
    # built-in arguments if ever possible a plugin has similarly named
    # plugin display filters (which it shouldn't!)
    plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
    for plugin in plugins:
        plugin = str(plugin)  # unicode->str for simplicity of the dict
        state = cmds.modelEditor(panel, query=True, queryPluginObjects=plugin)
        viewport_options[plugin] = state

    for key in ViewportOptions:
        viewport_options[key] = cmds.modelEditor(
            panel, query=True, **{key: True})

    viewport2_options = {}
    for key in Viewport2Options.keys():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        try:
            viewport2_options[key] = cmds.getAttr(attr)
        except ValueError:
            continue

    return {
        "camera": camera,
        "display_options": display_options,
        "camera_options": camera_options,
        "viewport_options": viewport_options,
        "viewport2_options": viewport2_options
    }
Beispiel #21
0
 def setDefaultConfig(self):
     
     #STATIC PREFS
     # tumble config
     #cmds.tumbleCtx( 'tumbleContext', edit=True, alternateContext=True, tumbleScale=1.0, localTumble=0, autoOrthoConstrain=False, orthoLock=False)
     cmds.tumbleCtx( 'tumbleContext', edit=True, alternateContext=True, tumbleScale=1.0, localTumble=0)
     cmds.dollyCtx( 'dollyContext', edit=True, alternateContext=True, scale=1.0, localDolly=True, centerOfInterestDolly=False)
     #timeline ticks display
     G.playBackSliderPython  = G.playBackSliderPython or mel.eval('$aTools_playBackSliderPython=$gPlayBackSlider')
     cmds.timeControl(G.playBackSliderPython, edit=True, showKeys="mainChannelBox", showKeysCombined=True, animLayerFilterOptions="active") 
     #tickDrawSpecial Color
     cmds.displayRGBColor('timeSliderTickDrawSpecial',1,1,.4)
     
     
     
     #CUSTOMIZABLE PREFS
     for loopPref in PREFS:
         name    = loopPref["name"]
         self.setPref(name, True)
Beispiel #22
0
def setViewportQuality():
    global modelEditors
    global backgroundColors
    backgroundColors.append(cmds.displayRGBColor('background',q=True))
    backgroundColors.append(cmds.displayRGBColor('backgroundTop',q=True))
    backgroundColors.append(cmds.displayRGBColor('backgroundBottom',q=True))
    cmds.displayRGBColor('background', 1, 1, 1)
    cmds.displayRGBColor('backgroundTop', 0.762112, 0.87892, 1)
    cmds.displayRGBColor('backgroundBottom', 1, 1, 1)

    for i in cmds.lsUI(panels=True):
        if cmds.modelEditor(i, query=True, exists=True):
            sts = cmds.modelEditor(i, query=True, stateString=True)
            sts = sts.replace("$editorName", i)
            modelEditors.append(sts)
            cmds.modelEditor(i, edit=True, displayAppearance="smoothShaded", lineWidth=2)
Beispiel #23
0
def mhCreateRGBSlider(udColorIndex, parentLayout):
    rgbValue = cmds.displayRGBColor('userDefined%d' % udColorIndex, query=True)
    cmds.colorSliderButtonGrp(
        'mhCustomColorButtonGrp%d' % udColorIndex,
        parent=parentLayout,
        label='userColor %d' % udColorIndex,
        buttonCommand='mhSetCustomColor(%d)' % udColorIndex,
        buttonLabel='assign',
        rgb=rgbValue,
        symbolButtonDisplay=False,
        changeCommand='mhUpdateCustomColor(%d)' % udColorIndex)
def createIcon():
    frameNumber = mc.currentTime (q=1)
    mc.setAttr("defaultHardwareRenderGlobals.startFrame",l=False)
    mc.setAttr("defaultHardwareRenderGlobals.endFrame",l=False)
    mc.setAttr("defaultHardwareRenderGlobals.byFrame",l=False)

    mc.setAttr("defaultHardwareRenderGlobals.startFrame",frameNumber)
    mc.setAttr("defaultHardwareRenderGlobals.endFrame" ,frameNumber)
    mc.setAttr("defaultHardwareRenderGlobals.extension",1)      
    mc.setAttr("defaultHardwareRenderGlobals.backgroundColor", 0.75 ,0.75 ,0.75,type='double3')
    mc.setAttr("defaultHardwareRenderGlobals.imageFormat",20)

    poseLibCaptureCameraBGColor = ( 0.75,0.75,0.75 )
    poseLibIconsSize = ( 104, 82 )
    poseLibIconsBGColor = (.4, .4, .5)
    
    currentBGColor = mc.displayRGBColor('background',q=1)
    mc.displayRGBColor('background',poseLibCaptureCameraBGColor[0],poseLibCaptureCameraBGColor[1],poseLibCaptureCameraBGColor[2])

    # Here we set the default hardware render globals resolution and aspect ratio.
    mc.setAttr('defaultHardwareRenderGlobals.filename',"iconTmp",type="string")
    mc.setAttr('defaultHardwareRenderGlobals.resolution','104x82 104 82 0',type="string")

    # Do the render.
    

    # Here we resize the gl frame to match the correct render resolution.
    mc.frameLayout('glRenderFrame',e=1,m=1,width=(poseLibIconsSize[0]+2),height=(poseLibIconsSize[1]+2))
    #mc.rowLayout(iconCaptureRL,e=1,cw=[2,106])

    # Look through the poseLib camera we just created.
    mc.glRenderEditor('hardwareRenderViewBis',e=1,lt='poseLibCaptureCamera')

    # Warning: This crashes Maya in certain scenes: 2600/4, or 1402/25, or 702/68.
    #mc.glRender(e=1,cf=frameNumber,accumBufferPasses=4,transformIcons= 0,edgeSmoothness=1.0,aam="gaussian")
    mc.glRender(rs='hardwareRenderViewBis')

    # Put back the background color the way it was.
    mc.displayRGBColor ("background",currentBGColor[0],currentBGColor[1],currentBGColor[2])
    print 'Icon Creation Done...'
Beispiel #25
0
def setup_bgColor(mode = 'gray', reverse = False):
    
    
    if mode == 'resetAll':
        mc.displayRGBColor(rf=True)
        return
    
    d_color = d_bg_presets.get(mode)
    if not d_color:
        raise ValueError,"Invalid mode: {0}".format(mode)
    
    if reverse:
        _top = d_color['bottom']
        _bottom = d_color['top']        
    else:
        _top = d_color['top']
        _bottom = d_color['bottom']
    
    mc.displayRGBColor( 'backgroundTop', _top[0],_top[1],_top[2]  )
    mc.displayRGBColor( 'backgroundBottom', _bottom[0],_bottom[1],_bottom[2]  )
    
        
    

    
    
Beispiel #26
0
def setViewportQuality():
    global modelEditors
    global backgroundColors
    backgroundColors.append(cmds.displayRGBColor('background', q=True))
    backgroundColors.append(cmds.displayRGBColor('backgroundTop', q=True))
    backgroundColors.append(cmds.displayRGBColor('backgroundBottom', q=True))
    cmds.displayRGBColor('background', 1, 1, 1)
    cmds.displayRGBColor('backgroundTop', 0.762112, 0.87892, 1)
    cmds.displayRGBColor('backgroundBottom', 1, 1, 1)

    for i in cmds.lsUI(panels=True):
        if cmds.modelEditor(i, query=True, exists=True):
            sts = cmds.modelEditor(i, query=True, stateString=True)
            sts = sts.replace("$editorName", i)
            modelEditors.append(sts)
            cmds.modelEditor(i,
                             edit=True,
                             displayAppearance="smoothShaded",
                             lineWidth=2)
    def get_outputs(self):
        outputs = {}
        if self.override.isChecked():
            outputs["displayGradient"] = self.display_gradient()
            for label, widget in self._colors.items():
                outputs[label] = widget.color
        else:
            # Parse active color settings
            outputs["displayGradient"] = cmds.displayPref(query=True,
                                                          displayGradient=True)
            for key in COLORS.keys():
                color = cmds.displayRGBColor(key, query=True)
                outputs[key] = color

        return {"display_options": outputs}
def parse_view(panel):
    """Parse the scene, panel and camera for their current settings

    Example:
        >>> parse_view("modelPanel1")

    Arguments:
        panel (str): Name of modelPanel

    """

    camera = cmds.modelPanel(panel, query=True, camera=True)

    # Display options
    display_options = {}
    for key in DisplayOptions:
        if key in _DisplayOptionsRGB:
            display_options[key] = cmds.displayRGBColor(key, query=True)
        else:
            display_options[key] = cmds.displayPref(query=True, **{key: True})

    # Camera options
    camera_options = {}
    for key in CameraOptions:
        camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))

    # Viewport options
    viewport_options = {}
    for key in ViewportOptions:
        viewport_options[key] = cmds.modelEditor(panel,
                                                 query=True,
                                                 **{key: True})

    viewport2_options = {}
    for key in Viewport2Options.keys():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        try:
            viewport2_options[key] = cmds.getAttr(attr)
        except ValueError:
            continue

    return {
        "camera": camera,
        "display_options": display_options,
        "camera_options": camera_options,
        "viewport_options": viewport_options,
        "viewport2_options": viewport2_options
    }
Beispiel #29
0
def restoreViewportQuality():
    global modelEditors
    global backgroundColors
    bc = backgroundColors
    cmds.displayRGBColor('background', bc[0][0], bc[0][1], bc[0][2])
    cmds.displayRGBColor('backgroundTop', bc[1][0], bc[1][1], bc[1][2])
    cmds.displayRGBColor('backgroundBottom', bc[2][0], bc[2][1], bc[2][2])

    for e in modelEditors:
        mel.eval(e)
Beispiel #30
0
def restoreViewportQuality():
    global modelEditors
    global backgroundColors
    bc = backgroundColors
    cmds.displayRGBColor('background', bc[0][0], bc[0][1], bc[0][2])
    cmds.displayRGBColor('backgroundTop', bc[1][0], bc[1][1], bc[1][2])
    cmds.displayRGBColor('backgroundBottom', bc[2][0], bc[2][1], bc[2][2])

    for e in modelEditors:
        mel.eval(e)
Beispiel #31
0
def parse_view(panel):
    """Parse the scene, panel and camera for their current settings

    Example:
        >>> parse_view("modelPanel1")

    Arguments:
        panel (str): Name of modelPanel

    """

    camera = cmds.modelPanel(panel, query=True, camera=True)

    # Display options
    display_options = {}
    for key in DisplayOptions:
        if key in _DisplayOptionsRGB:
            display_options[key] = cmds.displayRGBColor(key, query=True)
        else:
            display_options[key] = cmds.displayPref(query=True, **{key: True})

    # Camera options
    camera_options = {}
    for key in CameraOptions:
        camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))

    # Viewport options
    viewport_options = {}
    for key in ViewportOptions:
        viewport_options[key] = cmds.modelEditor(
            panel, query=True, **{key: True})

    viewport2_options = {}
    for key in Viewport2Options.keys():
        attr = "hardwareRenderingGlobals.{0}".format(key)
        try:
            viewport2_options[key] = cmds.getAttr(attr)
        except ValueError:
            continue

    return {
        "camera": camera,
        "display_options": display_options,
        "camera_options": camera_options,
        "viewport_options": viewport_options,
        "viewport2_options": viewport2_options
    }
Beispiel #32
0
def saveScreenshot(name, directory=TexturesDir):
    # 图片保存路径
    cmds.displayRGBColor('backgroundTop', 1, 1, 1)
    cmds.displayRGBColor('backgroundBottom', 1, 1, 1)
    cmds.displayRGBColor('background', 1, 1, 1)
    cmds.setAttr("perspShape.focalLength", 50)
    path = os.path.join(directory, '%s.jpg' % name)
    cmds.setAttr('hardwareRenderingGlobals.multiSampleEnable', 1)
    cmds.viewFit(f=1)  # 聚焦物体
    cmds.setAttr('defaultRenderGlobals.imageFormat', 8)  # 设置默认渲染器图片格式 8位jpg
    # 使用playblast 的方式保存截图
    cmds.playblast(completeFilename=path,
                   forceOverwrite=True,
                   format='image',
                   width=2048,
                   height=2048,
                   showOrnaments=False,
                   startTime=1,
                   endTime=1,
                   viewer=False)
    cmds.displayRGBColor(rs=True)

    return path
Beispiel #33
0
    def get_outputs(self):
        """Get the plugin outputs that matches `capture.capture` arguments

        Returns:
            dict: Plugin outputs

        """

        outputs = {}
        if self.override.isChecked():
            outputs["displayGradient"] = self.display_gradient()
            for label, widget in self._colors.items():
                outputs[label] = widget.color
        else:
            # Parse active color settings
            outputs["displayGradient"] = cmds.displayPref(query=True,
                                                          displayGradient=True)
            for key in COLORS.keys():
                color = cmds.displayRGBColor(key, query=True)
                outputs[key] = color

        return {"display_options": outputs}
def viewportColor(BG):
    if BG == 'gradGrey':
        cmds.displayPref(dgr=True)
    elif BG == 'Grey':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', .631, .631, .631)
    elif BG == 'Green':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', 0, 1, 0)
    elif BG == 'Blue':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', 0, 0, 1)
    elif BG == 'Red':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', 1, 0, 0)
    elif BG == 'White':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', 1, 1, 1)
    elif BG == 'Black':
        cmds.displayPref(dgr=False)
        cmds.displayRGBColor('background', 0, 0, 0)
    else:
        print 'Error: There was a problem with setting the camera viewport background color'
Beispiel #35
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)
import maya.cmds as cmds
import datetime

i = datetime.datetime.now()
currentTime = i.strftime('%Y-%m-%d')

# increment and save
# cmds.file(force=True, save=True, options="v=0");

# get scene file name to name the playblast
pbFileName = cmds.file(q=True, sn=True, shn=True)

# set bg color
cmds.displayRGBColor('background', 0, 1, 0)

# render playblast
cmds.playblast(format="qt",
               filename="movies/" + currentTime + "/" + pbFileName[:-3],
               clearCache=True,
               viewer=True,
               showOrnaments=False,
               fp=4,
               percent=100,
               compression="H.264",
               quality=75,
               widthHeight=[1280, 720])

# set bg color back
cmds.displayRGBColor('background', rs=True)
Beispiel #37
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)
Beispiel #38
0
 def setViewportOptions(self, *args):
     '''
     
     '''
     cmds.select(self._IScontextTool._mVoroObject)
     mel.eval("viewFit")
     
     # List all unselected objects
     self._IScontextTool._mObjectsToHide = mel.eval('listUnselected')
     
     # Display hard edge color change
     bHardEdge = False
     displayColors = cmds.displayRGBColor(list = True)
     for d in displayColors:
         d = d.split()[0]
         if d == 'hardedge':
             bHardEdge = True
             break
     
     if bHardEdge:
         if int(cmds.about(version = True).split()[0]) > 2015:
             cmds.displayRGBColor('hardedge', .2, .2, .2)
         else:
             cmds.displayRGBColor('hardedge', .15, .15, .15)
     
     # Switch to Persp/Outliner Panel and look through modelPanel4 (perspective)        
     mel.eval('setNamedPanelLayout "Persp/Outliner"')
     mel.eval('lookThroughModelPanel persp modelPanel4')
     
     # Switch to Viewport 2.0
     if cmds.modelEditor('modelPanel4', q = True, rnm = True) != 'vp2Renderer':
         mel.eval('setRendererInModelPanel "ogsRenderer" modelPanel4') 
     
     # Disable HeadsUpDisplay to display current viewport Renderer
     if (cmds.optionVar(exists = 'viewportRendererVisibility')):
         mel.eval("setViewportRendererVisibility 0")
     
     # Enable InViewMessages
     if (cmds.optionVar(exists = 'inViewMessageEnable')):
         cmds.optionVar(iv = ('inViewMessageEnable', 1))
         self._IScontextTool._mInViewMessage = True
     
     # Enable AA for Viewport 2.0
     if cmds.objExists('hardwareRenderingGlobals'):
         if (cmds.attributeQuery('lineAAEnable', node = 'hardwareRenderingGlobals', exists = True)):
             cmds.setAttr("hardwareRenderingGlobals.lineAAEnable", True)
         if (cmds.attributeQuery('multiSampleEnable', node = 'hardwareRenderingGlobals', exists = True)):
             cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", True)       
     
     # Turns HUD on, wireframeOnShaded on for all versions
     cmds.modelEditor('modelPanel4', e = True, hud = True)
     cmds.modelEditor('modelPanel4', e = True, wos = True)        
     cmds.modelEditor('modelPanel4', e = True, xray = False)       
     
     # Turns Gamma Viewport correction on if Maya version is equal or greater than 2016
     if int(cmds.about(version = True).split()[0]) > 2015:
         cmds.modelEditor('modelPanel4', e = True, cmEnabled = True)            
         self._IScontextTool._mGammaCorrect = True        
     
     # Turns the ground plane display off in all windows
     cmds.modelEditor('modelPanel4', edit = True, grid = False)
     
     # Disable Mesh Drawing for FractureFX    
     fxWorld = cmds.ls(type = 'fxWorld')
     if fxWorld:
         for w in fxWorld:                
             cmds.setAttr(w + '.drawMesh', False)                                
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)
Beispiel #40
0
    def _publish_fx_renders_for_item(self, item, output, work_template, primary_publish_path, sg_task, comment, thumbnail_path, progress_cb):
        """
        Render the FX Splashes (any nParticles) with Hardware Render Buffer (HWB)
        """
        ## Do the regular Shotgun processing now
        group_name = item['name'] # spriteSpray_nParticle_T_RShape
        debug(app = None, method = '_publish_fx_renders_for_item', message =  'group_name: %s' % group_name, verbose = False)

        tank_type = 'Rendered Image' # Alembic Cache
        debug(app = None, method = '_publish_fx_renders_for_item', message =  'tank_type: %s' % tank_type, verbose = False)

        publish_template = output["publish_template"] # <Sgtk TemplatePath maya_shot_fxRenderFinal: episodes/{Sequence}/{Shot}//FxLayers/R{version}>
        debug(app = None, method = '_publish_fx_renders_for_item', message =  'publish_template: %s' % publish_template, verbose = False)

        # Get the current scene path and extract fields from it
        # Using the work template:
        scene_path = os.path.abspath(cmds.file(query=True, sn= True)) # I:\bubblebathbay\episodes\ep106\ep106_sh030\FX\work\maya\ep106sh030.v025.ma
        debug(app = None, method = '_publish_fx_renders_for_item', message =  'scene_path: %s' % scene_path, verbose = False)

        fields = work_template.get_fields(scene_path) # {'Shot': u'ep106_sh030', 'name': u'ep106sh030', 'Sequence': u'ep106', 'Step': u'FX', 'version': 25, 'group_name': u'spriteSpray_nParticle_T_RShape'}

        publish_version = fields["version"]

        ## Update fields with the group_name
        fields["group_name"] = group_name

        ## Get episode and shot name from field directly
        epShotName = fields["name"]

        ## create the publish path by applying the fields
        ## with the publish template:
        publish_path = publish_template.apply_fields(fields) # K:\bubblebathbay\episodes\ep106\ep106_sh030\FxLayers\R025

        ## Make the publish directory for images rendering to be placed
        if not os.path.isdir(publish_path):
            os.mkdir(publish_path)

        # ## Hardware Render Buffer settings (LEGACY FOR NOW)
        # ## Get shotCam
        # shotCam = []
        # for cam in cmds.ls(cameras = 1):
        #     if not cmds.camera(cam, query = 1, startupCamera = 1):
        #         transform = cmds.listRelatives(cam, parent = True, fullPath = True)[0]
        #         if cmds.objExists('%s.type' % transform):
        #             if cmds.getAttr('%s.type' % transform) == 'shotCam':
        #                 shotCam.append(transform)
        #
        # if shotCam:
        #     debug(app = None, method = '_publish_fx_renders_for_item', message =  'shotCam for Hardware Render Buffer: %s' % shotCam[0], verbose = False)
        #
        #     ## Set the necessary correct settings for the HWB
        #     mel.eval('glRenderWin;')
        #     cmds.setAttr('defaultHardwareRenderGlobals.filename', epShotName, type = 'string')
        #     cmds.setAttr('defaultHardwareRenderGlobals.extension', 4)
        #     cmds.setAttr('defaultHardwareRenderGlobals.startFrame', cmds.playbackOptions(q = True, min = True))
        #     cmds.setAttr('defaultHardwareRenderGlobals.endFrame', cmds.playbackOptions(q = True, max = True))
        #     cmds.setAttr('defaultHardwareRenderGlobals.byFrame', 1)
        #     cmds.setAttr('defaultHardwareRenderGlobals.imageFormat', 19) # TARGA
        #     cmds.setAttr('defaultHardwareRenderGlobals.resolution', 'HD_720 1280 720 1.777', type = 'string')
        #     cmds.setAttr('defaultHardwareRenderGlobals.alphaSource', 0)
        #     cmds.setAttr('defaultHardwareRenderGlobals.writeZDepth', 0)
        #     cmds.setAttr('defaultHardwareRenderGlobals.lightingMode', 0)
        #     cmds.setAttr('defaultHardwareRenderGlobals.drawStyle', 3)
        #     cmds.setAttr('defaultHardwareRenderGlobals.texturing', 1)
        #     cmds.setAttr('defaultHardwareRenderGlobals.lineSmoothing', 1)
        #     cmds.setAttr('defaultHardwareRenderGlobals.fullImageResolution', 1)
        #     cmds.setAttr('defaultHardwareRenderGlobals.geometryMask', 1)
        #     cmds.setAttr('defaultHardwareRenderGlobals.backgroundColor', 0, 1, 0, type = 'double3')
        #     cmds.glRenderEditor('hardwareRenderView', edit = True, lookThru = shotCam[0])
        #     cmds.workspace(fileRule = ['images', publish_path])
        #     cmds.glRender(renderSequence = 'hardwareRenderView')

        ###############################################################################################
        ## Playblast Render
        ###############################################################################################
        # Get shotCams
        non_startup_cams = [cmds.listRelatives(cam, parent = True, fullPath = True)[0] for cam in cmds.ls(cameras = True) if not cmds.camera(cam, query = True, startupCamera = True)]
        shotCam = [cam for cam in non_startup_cams if cmds.objExists('%s.type' % cam)]
        shotCamShape = [cmds.listRelatives(cam, shapes = True, fullPath = True)[0] for cam in shotCam if cmds.getAttr('%s.type' % cam) == 'shotCam']

        # Get model panel
        model_panel = cmds.getPanel(withFocus = True)

        proceed = False
        if not shotCamShape:
            cmds.warning('No shotCam found in scene, please fix it first...!')
        else:
            if not cmds.objExists('ocean_dispShader'):
                cmds.warning('ocean_dispShader not found in scene, please fix it first...!')
            else:
                if not cmds.objExists('oceanPreviewPlane_heightF'):
                    cmds.warning('oceanPreviewPlane_heightF not found in scene, please fix it first...!')
                else:
                    if not 'modelPanel' in model_panel:
                        cmds.warning('No valid modelPanel in focus for playblasting...!')
                    else:
                        proceed = True

        if proceed == True:
            for cam in shotCamShape:
                ## Set appropriate camera display option settings for optimal playblasting
                cmds.setAttr('%s.overscan' % cam, 1)
                cmds.setAttr('%s.displayFilmGate' % cam, 0)
                cmds.setAttr('%s.displayResolution' % cam, 0)
                cmds.setAttr('%s.displayGateMask' % cam, 0)
                cmds.setAttr('%s.displayFieldChart' % cam, 0)
                cmds.setAttr('%s.displaySafeAction' % cam, 0)
                cmds.setAttr('%s.displaySafeTitle' % cam, 0)
                cmds.setAttr('%s.displayFilmPivot' % cam, 0)
                cmds.setAttr('%s.displayFilmOrigin' % cam, 0)

            ## Set appropriate "SHOW" to modelPanel
            cmds.modelEditor(model_panel, edit = True, displayLights = 'none')
            cmds.modelEditor(model_panel, edit = True, displayLights = 'default', camera = shotCamShape[0], allObjects = False, polymeshes = True, nParticles = True, manipulators = True, pluginShapes = True, pluginObjects = ['gpuCacheDisplayFilter', True], useDefaultMaterial = True, displayAppearance = 'flatShaded', displayTextures = True)

            ## Set lambert1 to green matte
            cmds.setAttr("lambert1.color", 0, 10, 0, type = 'double3')
            cmds.setAttr("lambert1.transparency", 0, 0, 0, type = 'double3')
            cmds.setAttr("lambert1.ambientColor", 0, 10, 0, type = 'double3')
            cmds.setAttr("lambert1.incandescence", 0, 10, 0, type = 'double3')
            cmds.setAttr("lambert1.diffuse", 0)
            cmds.setAttr("lambert1.translucence", 0)
            cmds.setAttr("lambert1.translucenceDepth", 0)
            cmds.setAttr("lambert1.translucenceFocus", 0)

            ## Set ocean shader to green matte
            if cmds.isConnected('ocean_dispShader.outColor', 'oceanPreviewPlane_heightF.color'):
                cmds.disconnectAttr('ocean_dispShader.outColor', 'oceanPreviewPlane_heightF.color')
                cmds.setAttr('oceanPreviewPlane_heightF.color', 0, 1, 0, type = 'double3')

            ## Set view port BG to green matte
            default_bg_color = cmds.displayRGBColor('background', q = True)
            default_bgTop_color = cmds.displayRGBColor('backgroundTop', q = True)
            default_bgBtm_color = cmds.displayRGBColor('backgroundBottom', q = True)
            cmds.displayRGBColor('background', 0, 1, 0)
            cmds.displayRGBColor('backgroundTop', 0, 1, 0)
            cmds.displayRGBColor('backgroundBottom', 0, 1, 0)

            ## Get timeslider min/max
            min = cmds.playbackOptions(min = True, q = True)
            max = cmds.playbackOptions(max = True, q = True)

            ## Force current time to min of time slider to avoid popping at frame 1 issue
            [cmds.currentTime(min) for i in range(2)]

            ## Now find the fx stuff and make sure the groups are visible and good for playblasting
            grps = ['OCEAN_hrc', 'oceanPreviewPlane_prv']
            for eachGrp in grps:
                if cmds.objExists(eachGrp):
                    cmds.setAttr('%s.visibility' % eachGrp, True)
            cmds.select(clear = True)

            ## Find all mesh in scene that has smoothed checked and Mentalray preview smooth them...
            mesh_with_smoothTag = [cmds.listRelatives(mesh, parent = True, fullPath = True)[0] for mesh in cmds.ls(type = 'mesh') if cmds.objExists('%s.smoothed' % cmds.listRelatives(mesh, parent = True, fullPath = True)[0])]
            mesh_with_smoothTag = [mesh for mesh in mesh_with_smoothTag if cmds.getAttr('%s.smoothed' % mesh)]
            [cmds.displaySmoothness(each, polygonObject = 3) for each in mesh_with_smoothTag if 'CHAR_' in each or 'PROP_' in each]

            ## Playblast rendering
            cmds.playblast( filename = os.path.join(publish_path, epShotName).replace('\\', '/'),
                            clearCache = True,
                            startTime = min,
                            endTime = max,
                            viewer = False,
                            forceOverwrite = True,
                            format = 'image',
                            compression = 'png',
                            framePadding = 4,
                            offScreen = True,
                            options = False,
                            percent = 100,
                            quality = 100,
                            sequenceTime = False,
                            showOrnaments = False,
                            widthHeight = [(1280 * 3), (720 * 3)]
                            )

            ## Find all mesh in scene and un-preview smooth them...
            [cmds.displaySmoothness(mesh, polygonObject = 1) for mesh in cmds.ls(type = 'mesh')]

            ## After playblast, set back the scene BG's color as default
            cmds.displayRGBColor('background', default_bg_color[0], default_bg_color[1], default_bg_color[2])
            cmds.displayRGBColor('backgroundTop', default_bgTop_color[0], default_bgTop_color[1], default_bgTop_color[2])
            cmds.displayRGBColor('backgroundBottom', default_bgBtm_color[0], default_bgBtm_color[1], default_bgBtm_color[2])

            ## Set appropriate "SHOW" to modelPanel back...
            cmds.modelEditor(model_panel, edit = True, useDefaultMaterial = False, displayTextures = False, displayAppearance = 'smoothShaded', activeOnly = False)

            ## Set lambert1 to default
            cmds.setAttr("lambert1.color", 0.5, 0.5, 0.5, type = 'double3')
            cmds.setAttr("lambert1.transparency", 0, 0, 0, type = 'double3')
            cmds.setAttr("lambert1.ambientColor", 0, 0, 0, type = 'double3')
            cmds.setAttr("lambert1.incandescence", 0, 0, 0, type = 'double3')
            cmds.setAttr("lambert1.diffuse", 0.8)
            cmds.setAttr("lambert1.translucence", 0)
            cmds.setAttr("lambert1.translucenceDepth", 0.5)
            cmds.setAttr("lambert1.translucenceFocus", 0.5)

            ## Set ocean shader to default color
            if not cmds.isConnected('ocean_dispShader.outColor', 'oceanPreviewPlane_heightF.color'):
                cmds.connectAttr('ocean_dispShader.outColor', 'oceanPreviewPlane_heightF.color', force = True)

            ## Finally after render, register publish to shotgun...
            self._register_publish(publish_path,
                                   group_name,
                                   sg_task,
                                   publish_version,
                                   tank_type,
                                   comment,
                                   thumbnail_path,
                                   [primary_publish_path])
            print 'Successfully rendered nParticles Splashes to %s...' % os.path.join(publish_path, epShotName).replace('\\', '/')
            print '=================================================='
def makePreview(file,
                camera,
                useDefaultMaterial,
                percent,
                quality,
                startFrame,
                endFrame,
                widthHeight,
                showOrnaments=1):
    #
    width, height = widthHeight
    #
    widthReduce = width
    heightReduce = height
    # Reduce Width and Height
    checkValue = max(widthHeight)
    if checkValue > 2048:
        if width > height:
            widthReduce = 2048
            heightReduce = 2048 * height / width
        if width < height:
            widthReduce = 2048 * width / height
            heightReduce = 2048
    widthHeightReduce = widthReduce, heightReduce
    #
    filePath = os.path.dirname(file)
    fileName = os.path.basename(file)
    #
    isMov = os.path.splitext(fileName)[-1] == '.mov'
    format = [os.path.splitext(fileName)[-1][1:], u'qt'][isMov]
    compression = [u'IYUV 编码解码器', u'H.264'][isMov]
    #
    prvName = os.path.splitext(file)[0]
    #
    prvWindow = "previewWindowName"
    removeMayaWindow(prvWindow)
    cmds.window(prvWindow, title='Animation Preview')
    paneLayout = cmds.paneLayout(width=widthReduce / 2,
                                 height=heightReduce / 2)
    animationView = cmds.modelPanel(label=prvWindow,
                                    parent=paneLayout,
                                    menuBarVisible=0,
                                    modelEditor=0,
                                    camera=camera)
    cmds.displayRGBColor('background', .25, .25, .25)
    cmds.displayRGBColor('backgroundTop', .25, .25, .25)
    cmds.displayRGBColor('backgroundBottom', .25, .25, .25)
    cmds.showWindow(prvWindow)

    # Set Maye View
    cmds.modelEditor(animationView,
                     edit=1,
                     activeView=1,
                     useDefaultMaterial=useDefaultMaterial,
                     wireframeOnShaded=0,
                     fogging=0,
                     dl='default',
                     twoSidedLighting=0,
                     allObjects=0,
                     manipulators=0,
                     grid=0,
                     hud=1,
                     sel=0)
    cmds.modelEditor(animationView,
                     edit=1,
                     activeView=1,
                     polymeshes=1,
                     subdivSurfaces=1,
                     fluids=1,
                     strokes=1,
                     nCloths=1,
                     nParticles=1,
                     pluginShapes=1,
                     pluginObjects=['gpuCacheDisplayFilter', 1],
                     displayAppearance='smoothShaded')
    # Video Preview
    cmds.playblast(startTime=startFrame,
                   endTime=endFrame,
                   format=format,
                   filename=prvName,
                   clearCache=1,
                   viewer=0,
                   showOrnaments=showOrnaments,
                   offScreen=1,
                   framePadding=4,
                   percent=percent,
                   compression=compression,
                   quality=quality,
                   widthHeight=widthHeightReduce)
    # # Image Preview
    # midFrame = int((endFrame - startFrame) / 2 + startFrame)
    # frameRange = [startFrame, midFrame, endFrame]
    # frameDic = {startFrame: '0000', midFrame: '0001', endFrame: '0002'}
    # for frame in frameRange:
    #     cmds.playblast( startTime=frame,
    #                     endTime=frame,
    #                     format='iff',
    #                     filename=prvName,
    #                     sequenceTime=0,
    #                     clearCache=1,
    #                     viewer=0,
    #                     showOrnaments=0,
    #                     offScreen=0,
    #                     framePadding=4,
    #                     percent=percent,
    #                     compression='jpg',
    #                     quality=quality)
    #     previewFile = prvName + '_' + frameDic[frame] + '.jpg'
    #     if os.path.exists(previewFile):
    #         os.remove(previewFile)
    #     os.rename(prvName + '.' + str(frame).zfill(4) + '.jpg', previewFile)
    # Remove Widow
    removeMayaWindow(prvWindow)
Beispiel #42
0
    def background(self, values):
        '''Set the background color of the Viewport.

        :param values: RGB value'''

        cmds.displayRGBColor('background', *values)
Beispiel #43
0
def defaultScriptEditorColors():
    """
    set the default maya environment color scheme
    """
    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)
Beispiel #44
0
def customScriptEditorColors():
    """
    set custom maya environment color scheme
    """
    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)
Beispiel #45
0
    def background(self, values):
        '''Set the background color of the Viewport.

        :param values: RGB value'''

        cmds.displayRGBColor('background', *values)
    def process(self, instance):
        self.log.info("Extracting capture..")
        components = instance.data['ftrackComponents'].copy()
        self.log.debug('Components: {}'.format(components))

        camera = instance[0]

        if 'persp' in camera:
            self.log.info("If you want movie review, create a camera with \
                          '_CAM' suffix")
            return

        format = instance.data('format') or 'qt'
        compression = instance.data('compression') or 'h264'
        off_screen = instance.data('offScreen', False)
        maintain_aspect_ratio = instance.data('maintainAspectRatio', True)

        try:
            preset = capture.parse_active_view()

            if 'show' in instance.data():
                self.log.info("Overriding show: %s" % instance.data['show'])
                for nodetype in instance.data['show']:
                    # self.log.info("Overriding show: %s" % nodetype)
                    if hasattr(preset['viewport_options'], nodetype):
                        setattr(preset['viewport_options'], nodetype, True)
                    else:
                        self.log.warning("Specified node-type in 'show' not "
                                         "recognised: %s" % nodetype)
        except:
            camera_shape = cmds.listRelatives(camera, shapes=True)[0]

            preset = {
                "camera": camera,
                "width": cmds.getAttr("defaultResolution.width"),
                "height": cmds.getAttr("defaultResolution.height"),
                "camera_options": type("CameraOptions", (object, capture.CameraOptions,), {
                    "displayFilmGate": cmds.getAttr(camera_shape + ".displayFilmGate"),
                    "displayResolution": cmds.getAttr(camera_shape + ".displayResolution"),
                    "displaySafeAction": cmds.getAttr(camera_shape + ".displaySafeAction"),
                }),
                "viewport_options": type("ViewportOptions", (object, capture.ViewportOptions,), {
                    "useDefaultMaterial": False,
                    "wireframeOnShaded": False,
                    # "displayAppearance": cmds.modelEditor(panel, query=True, displayAppearance=True),
                    "displayTextures": True,
                    "displayLights": True,
                    "shadows": True,
                }),
                "display_options": type("DisplayOptions", (object, capture.DisplayOptions,), {
                    "background": cmds.displayRGBColor('background', q=True),
                    "backgroundTop": cmds.displayRGBColor('backgroundTop', q=True),
                    "backgroundBottom": cmds.displayRGBColor('backgroundBottom', q=True),
                    'displayGradient': cmds.displayPref(dgr=True, q=True),
                }),
            }


        # Ensure name of camera is valid
        sourcePath = os.path.normpath(instance.context.data('currentFile'))
        path, extension = os.path.splitext(sourcePath)
        path = (path + ".png")

        # Ensure name of camera is valid
        sourcePath = os.path.normpath(instance.context.data('currentFile'))
        path, extension = os.path.splitext(sourcePath)


        if format == 'image':
            # Append sub-directory for image-sequence
            path = os.path.join(path, camera)
        else:
            path = (path + ".mov")

        self.log.info("Outputting to %s" % path)

        with maintained_time():
            output = capture.capture(
                # camera=camera,
                # width=width,
                # height=height,
                filename=path,
                # start_frame=start_frame,
                # end_frame=end_frame,
                format=format,
                viewer=False,
                compression=compression,
                off_screen=off_screen,
                maintain_aspect_ratio=maintain_aspect_ratio,
                overwrite=True,
                quality=80,
                **preset
                )


        instance.data["outputPath_qt"] = output