Пример #1
0
def deleteLayer(layerName):
    layer = renderSetup.instance().getRenderLayer(layerName)
    if layer.isVisible():
        renderSetup.instance().switchToLayer(
            renderSetup.instance().getDefaultRenderLayer())
    renderSetup.instance().detachRenderLayer(layer)
    renderLayer.delete(layer)
Пример #2
0
 def clearAll(self):
     """ Clear the render setup by deleting all its render layers """
     layers = self.getRenderLayers()
     for layer in layers:
         if layer.isVisible():
             self.switchToLayer(self.getDefaultRenderLayer())
         self.detachRenderLayer(layer)
         renderLayer.delete(layer)
Пример #3
0
def set_gpu_color_override(model_group, color):
    """ Creates a Maya render layer to override GPU caches display color
    """

    try:
        cmds.undoInfo(openChunk=True)

        # creates a new instance of the render setup and force clear
        render_setup = renderSetup.instance()
        render_setup.clearAll()

        # force deleting unused shading nodes
        mel.eval('MLdeleteUnused;')

        # creates render layer
        color_layer = render_setup.createRenderLayer("cache_manager_rl")

        # creates collection
        collection = color_layer.createCollection("cache_manager_override")

        # adds model group into the collection of the render layer
        collection.getSelector().setPattern(model_group)

        # creates shader
        mat = cmds.shadingNode("phong",
                               asShader=True,
                               name="cache_manager_display_phong")
        cmds.setAttr("{}.color".format(mat), color[0], color[1], color[2])
        cmds.setAttr("{}.specularColor".format(mat), 0.1, 0.1, 0.1)

        # create override and sets shader
        override = collection.createOverride('shading_override',
                                             typeIDs.shaderOverride)
        override.setShader(mat)

        render_setup.switchToLayer(color_layer)
        yield

    finally:
        # switch back to default render layer
        render_setup.switchToLayer(render_setup.getDefaultRenderLayer())

        # deletes cache manager render layer
        render_setup.detachRenderLayer(color_layer)
        renderLayer.delete(color_layer)

        # force deleting unused shading nodes
        mel.eval('MLdeleteUnused;')
        cmds.undoInfo(closeChunk=True)
Пример #4
0
def clear_rsl_by_name(lyr_name):
    """Clear/Delete layer by name

    Args:
        lyr_name (str): Name of the layer to delete
    """
    try:
        pm.undoInfo(openChunk=True)
        rs = renderSetup.instance()
        layer_list = rs.getRenderLayers()
        for layer in layer_list:
            if not layer.name() == lyr_name:
                continue
            if layer.isVisible():
                rs.switchToLayer(rs.getDefaultRenderLayer())
            rs.detachRenderLayer(layer)
            renderLayer.delete(layer)
        mel.eval('MLdeleteUnused;')
    finally:
        pm.undoInfo(closeChunk=True)
Пример #5
0
def delete_node(node):
    """Convenience method for deleting dag nodes and render layers."""
    if isinstance(node, renderLayer.RenderLayer):
        renderLayer.delete(node)
    else:
        pymel.core.delete(node)
def deleteLayer(layerName):
    layer = rs.getRenderLayer(layerName)
    if layer.isVisible():
        rs.switchToLayer(rs.getDefaultRenderLayer())
    rs.detachRenderLayer(layer)
    renderLayer.delete(layer)
Пример #7
0
def deleteAllRenderLayer():
    render_layers = renderSetup.instance().getRenderLayers()
    for i in render_layers:
        renderLayer.delete(i)