Example #1
0
def _processClass(nodeType):
    '''
    convert the passed node type's classification string to a tuple containing a formatted path string
    compatible with the node lister and the runtime classification.
    
    e.g. from 'aiStandard' to ('rendernode/arnold/shader/surface', 'asShader', 'Arnold/Shader/Surface')
    '''
    for klass in pm.getClassification(nodeType):
        if klass.startswith('rendernode/arnold'):
            parts = klass.split('/')
            if len(parts) < 3:
                return (klass, 'asUtility', 'Arnold')
            else :
                # remove the rendernode first token
                parts.pop(0)
                label = '/'.join([utils.prettify(x) for x in parts])
                cat = 'asUtility'
                # find a runtime classification. try matching from most specific to most generic
                # first token is always 'arnold':
                parts.pop(0)
                while parts:
                    try:
                        cat = CATEGORY_TO_RUNTIME_CLASS[tuple(parts)]
                    except KeyError:
                        parts.pop(-1)
                    else:
                        break
                return (klass, cat, label)
    return (None, None, None)
Example #2
0
def _processClass(nodeType):
    '''
    convert the passed node type's classification string to a tuple containing a formatted path string
    compatible with the node lister and the runtime classification.
    
    e.g. from 'aiStandard' to ('rendernode/arnold/shader/surface', 'asShader', 'Arnold/Shader/Surface')
    '''
    for klass in pm.getClassification(nodeType):
        if klass.startswith('rendernode/arnold'):
            parts = klass.split('/')
            if len(parts) < 3:
                return (klass, 'asUtility', 'Arnold')
            else:
                # remove the rendernode first token
                parts.pop(0)
                label = '/'.join([utils.prettify(x) for x in parts])
                cat = 'asUtility'
                # find a runtime classification. try matching from most specific to most generic
                # first token is always 'arnold':
                parts.pop(0)
                while parts:
                    try:
                        cat = CATEGORY_TO_RUNTIME_CLASS[tuple(parts)]
                    except KeyError:
                        parts.pop(-1)
                    else:
                        break
                return (klass, cat, label)
    return (None, None, None)
Example #3
0
 def createRenderNodeCallback(self, postCommand, nodeType):
     #log.debug("createRenderNodeCallback postCmd {0} nodeType {1}".format(postCommand, nodeType))
     for c in pm.getClassification(nodeType):
         if self.rendererName.lower() in c:
             #log.debug("Found {0} node: {1}".format(self.rendererName.lower(), nodeType))
             buildNodeCmd = "import {0} as rcall; rcall.theRenderer().createRenderNode(nodeType=\\\"{1}\\\")".format(self.moduleName, nodeType)
             buildNodeCmd = "string $cmd = \"{0}\"; python($cmd);".format(buildNodeCmd)
             return buildNodeCmd
Example #4
0
 def createRenderNodeCallback(self, postCommand, nodeType):
     #log.debug("createRenderNodeCallback postCmd {0} nodeType {1}".format(postCommand, nodeType))
     for c in pm.getClassification(nodeType):
         if self.rendererName.lower() in c:
             buildNodeCmd = "import {0} as rcall; rcall.theRenderer().createRenderNode(nodeType=\\\"{1}\\\", postCommand='{2}')".format(self.moduleName, nodeType, postCommand)
             buildNodeCmd = "string $cmd = \"{0}\"; python($cmd);".format(buildNodeCmd)
             #log.debug("buildNodeCmd {0}".format(buildNodeCmd))
             return buildNodeCmd
def createRenderNodeCallback(postCommand, nodeType):
    logger.debug("createRenderNodeCallback called!")

    for c in pm.getClassification(nodeType):
        if 'appleseed' in c.lower():
            buildNodeCmd = "import appleseedMaya.callbacks; appleseedMaya.callbacks.createRenderNode(nodeType=\\\"{0}\\\", postCommand='{1}')".format(nodeType, postCommand)
            buildNodeCmd = "string $cmd = \"{0}\"; python($cmd);".format(buildNodeCmd)
            return buildNodeCmd
Example #6
0
def createRenderNodeCallback(postCommand, nodeType):
    logger.debug("createRenderNodeCallback called!")

    for c in pm.getClassification(nodeType):
        if 'appleseed' in c.lower():
            buildNodeCmd = "import appleseedMaya.callbacks; appleseedMaya.callbacks.createRenderNode(nodeType=\\\"{0}\\\", postCommand='{1}')".format(
                nodeType, postCommand)
            buildNodeCmd = "string $cmd = \"{0}\"; python($cmd);".format(
                buildNodeCmd)
            return buildNodeCmd
Example #7
0
    def is_attr_interesting(attr):
        if not attr:
            return True

        if not attr.isSettable() or not attr.isKeyable():
            return False

        classification = pymel.getClassification(attr.node().type())
        if any(True for token in classification if 'utility' in token):
            return False

        return True
Example #8
0
    def is_attr_interesting(attr):
        if not attr:
            return True

        if not attr.isSettable() or not attr.isKeyable():
            return False

        classification = pymel.getClassification(attr.node().type())
        if any(True for token in classification if 'utility' in token):
            return False

        return True
Example #9
0
    def update_attributes(self):
        # Get object
        button_value = self.select_button.get_value(static=True)
        if button_value != None:
            all_attributes = []
            attribute_lists = []

            existing_geo = [x for x in button_value if pm.objExists(x)]
            missing_geo = list(set(button_value) - set(existing_geo))
            for x in existing_geo:
                node_type = pm.nodeType(x)
                classifications = pm.getClassification(node_type)[-1]
                if node_type == "blendShape":
                    attribute_lists.append(pm.listAttr(str(x) + ".w", m=True))
                elif "utility" in classifications:
                    input_attr = pm.listAttr(x,
                                             keyable=True,
                                             visible=True,
                                             locked=False)
                    output_attr = pm.listAttr(x, output=True, readOnly=True)
                    attribute_lists.append(input_attr + output_attr)
                elif "deformer" in classifications:
                    input_attr = pm.listAttr(x,
                                             keyable=True,
                                             visible=True,
                                             locked=False)
                    output_attr = pm.listAttr(x, output=True, readOnly=True)
                    attribute_lists.append(input_attr + output_attr)
                else:
                    attribute_lists.append(
                        pm.listAttr(x,
                                    keyable=True,
                                    visible=True,
                                    locked=False,
                                    shortNames=False))

            #Sort and filter out only attributes existing in all controllers
            unice_attributes = set([x for y in attribute_lists for x in y])
            common_attributes = [
                x for x in unice_attributes
                if all(x in list for list in attribute_lists) == True
            ]
            self.attribute_button.set_options(sorted(common_attributes))
            self.attribute_button.setHidden(False)
            self.value["object"] = button_value
        else:
            self.attribute_button.setHidden(True)
            self.value["object"] = None
            self.value["attributes"] = ()
        self.emitter.value.emit(1)
def createRenderNode(nodeType=None, postCommand=None):
    nodeClass = None
    for cl in pm.getClassification(nodeType):
        if "appleseed/surface" in cl.lower():
            nodeClass = "shader"
        if "appleseed/texture" in cl.lower():
            nodeClass = "texture"

    if nodeClass == "shader":
        mat = pm.shadingNode(nodeType, asShader=True)
        shadingGroup = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name="{0}SG".format(mat))
        mat.outColor >> shadingGroup.surfaceShader
    else:
        mat = pm.shadingNode(nodeType, asTexture=True)

    if postCommand is not None:
        postCommand = postCommand.replace("%node", str(mat))
        postCommand = postCommand.replace("%type", '\"\"')
        pm.mel.eval(postCommand)
    return ""
Example #11
0
 def createRenderNode(self, nodeType=None, postCommand=None):
     print "createRenderNode nodeType ", nodeType, "postCommand", postCommand
     log.debug("createRenderNode callback for renderer {0} with node: {1}".format(self.rendererName.lower(), nodeType))
     nodeClass = None
     rendererName = self.rendererName.lower()
     for cl in pm.getClassification(nodeType):
         if (rendererName+"/material") in cl.lower():
             nodeClass = "shader"
         if (rendererName + "/texture") in cl.lower():
             nodeClass = "texture"
             
     if nodeClass == "shader":
         mat = pm.shadingNode(nodeType, asShader=True)
         shadingGroup = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name="{0}SG".format(mat))
         mat.outColor >> shadingGroup.surfaceShader
     else:
         mat = pm.shadingNode(nodeType, asTexture=True)
         
     if postCommand is not None:
         postCommand = postCommand.replace("%node", str(mat))
         postCommand = postCommand.replace("%type", '\"\"')
         pm.mel.eval(postCommand)
     return ""
Example #12
0
def createRenderNode(nodeType=None, postCommand=None):
    nodeClass = None
    for cl in pm.getClassification(nodeType):
        if "appleseed/surface" in cl.lower():
            nodeClass = "shader"
        if "appleseed/texture" in cl.lower():
            nodeClass = "texture"

    if nodeClass == "shader":
        mat = pm.shadingNode(nodeType, asShader=True)
        shadingGroup = pm.sets(renderable=True,
                               noSurfaceShader=True,
                               empty=True,
                               name="{0}SG".format(mat))
        mat.outColor >> shadingGroup.surfaceShader
    else:
        mat = pm.shadingNode(nodeType, asTexture=True)

    if postCommand is not None:
        postCommand = postCommand.replace("%node", str(mat))
        postCommand = postCommand.replace("%type", '\"\"')
        pm.mel.eval(postCommand)
    return ""
Example #13
0
 def createRenderNodeCallback(self, postCommand, nodeType):
     for c in pm.getClassification(nodeType):
         if self.rendererName.lower() in c.lower():
             buildNodeCmd = "import {0} as rcall; rcall.theRenderer().createRenderNode(nodeType=\\\"{1}\\\", postCommand='{2}')".format(self.moduleName, nodeType, postCommand)
             buildNodeCmd = "string $cmd = \"{0}\"; python($cmd);".format(buildNodeCmd)
             return buildNodeCmd
def isClassified(node, klass):
    nodeType = pm.nodeType(node)
    return klass in pm.getClassification(nodeType)