def shaderNetworkToDict(sel):

    tempDict = {}

    for s in sel:
        nodeAtts = cmds.attributeInfo(s, hidden=False)
        nodeMulti = cmds.attributeInfo(s, m=True)
        nodeType = cmds.nodeType(s)
        attrDict = {s: {"attr": {}, "nType": nodeType}}
        if nodeMulti:
            for a in nodeMulti:
                children = cmds.attributeQuery(a, node=s, listChildren=True)
                if children:

                    value = cmds.getAttr('%s.%s' % (s, a), multiIndices=True)
                    if value:
                        for v in value:
                            for child in children:
                                childAttr = '%s[%s].%s' % (a, v, child)
                                childAttrValue = cmds.getAttr('%s.%s[%s].%s' %
                                                              (s, a, v, child))
                                nodeAtts.append('%s[%s].%s' % (a, v, child))

        for a in nodeAtts:
            try:
                value = cmds.getAttr('%s.%s' % (s, a))
                if cmds.attributeQuery(a, node=s, ex=True) and value != "":
                    defaultValue = cmds.attributeQuery(a, node=s, ld=True)

                    if defaultValue == None and isinstance(value, basestring):
                        pass
                    elif len(defaultValue) == 1:
                        defaultValue = defaultValue[0]
                    elif len(defaultValue) > 1:
                        defaultValue = [tuple(defaultValue)]

                else:
                    #force attributes without defaults to the dictionary
                    defaultValue = ''

                if value != defaultValue:
                    #remove tuple from list
                    if isinstance(value, list):
                        value = tuple(value[0])
                    #add attr to attrDict

                    attrDict[s]['attr'][a] = value
            except:
                pass
        tempDict.update(attrDict)

    return tempDict
Ejemplo n.º 2
0
 def add_extra_attribute(self):
     current_attributes = mc.attributeInfo(self.beak_reflex_target,
                                           all=True)
     for attr in self.attributes:
         if attr in current_attributes:
             continue
         else:
             mc.addAttr(self.beak_reflex_target, ln=attr, dt='string')
Ejemplo n.º 3
0
    def on_action_add_switch(self, pos, menuPos):
        objs = cmds.ls(selection=True)
        obj = objs[0]
        attrs = cmds.attributeInfo(obj, e=True)

        attrMenu = QMenu(None)
        for attr in attrs:
            attrMenu.addAction(attr, partial(self.on_action_add_checkbox, pos, obj, attr))
        attrMenu.exec_(menuPos)
Ejemplo n.º 4
0
def excludeParentAttribute ():
    nodeType = ['controlPoint','geometryShape','containerBase' ]
    unExposeAttr = []
    for nde in nodeType:
        attrList = mc.attributeInfo( inherited=False, t=nde  )

        if attrList is not None:
            unExposeAttr.extend(attrList)
    return unExposeAttr
Ejemplo n.º 5
0
    def get_type_attributes(self, node_type, inherited, others, excluded_types):
        result_attrs = {}
        if inherited:
            type_attrs = cmds.attributeInfo(leaf=False, type=node_type)
        else:
            type_attrs = cmds.attributeInfo(inherited=False, leaf=False, logicalAnd=True, type=node_type)

        if type_attrs is not None:
            for attribute in type_attrs:
                if attribute not in ignore_attributes:
                    attr_type = cmds.attributeQuery(attribute, type=node_type, attributeType=True)
                    if attr_type not in ignore_types and attr_type not in excluded_types:
                        if others:
                            result_attrs[attribute] = attr_type
                        else:
                            if attr_type not in other_types_list:
                                result_attrs[attribute] = attr_type
        return result_attrs
Ejemplo n.º 6
0
def getUseColorWritableAttributes(node):
    if not mc.objExists(node):
        raise ValueError("Can not find node : {0}".format(node))
    all_useColor_attributes = [
        a for a in mc.attributeInfo(node, writable=True) if mc.attributeQuery(a, n=node, usedAsColor=True)
    ]
    # -
    if all_useColor_attributes:
        return all_useColor_attributes
    return []
def art3dPaintGetPaintableAttr(allowCustomAttrs=True):
    '''Return list of all the names of 
    all color attrs common (to all selected shader) paintable attributes.
    This includes custom attributes.
    '''

    shaderPaintableAttrs = []
    # Start with list of standard paintable attrs supplied by art3dPaintCtx (if not allowing custom attrs)
    explicitPaintableAttrs = set([str(attr) for attr in cmds.art3dPaintCtx(cmds.currentCtx(), q=True, attrnames=True).split()])
    if not allowCustomAttrs:
        shaderPaintableAttrs.append(explicitPaintableAttrs)
   
    # Retrieve paintable attrs from each shader    
    shaders = cmds.art3dPaintCtx(cmds.currentCtx(), q=True, shadernames=True).split()
    shaderTypesWithDisplacement = set([
        'lambert',
        'blinn',
        'phong',
        'phongE',
        'anisotropic',
        ])
    attrTypes = set([
        'float',
        'double',
        'float3',
        'double3',
        ])
    nonPaintableAttrs = set([
        'hardwareShader',
        ])
    for shader in shaders:
        # attrs explicitly specified or user-defined float,float3,double,double3 attrs
        paintableAttrs = cmds.attributeInfo(shader, logicalAnd=True, writable=True, leaf=False, bool=False, enumerated=False, hidden=False)
        paintableAttrs = set([str(attr) for attr in paintableAttrs if ((attr in explicitPaintableAttrs) or (cmds.listAttr(shader, userDefined=True, st=attr) and (cmds.getAttr('%s.%s'%(shader,attr), type=True) in attrTypes)))])
        paintableAttrs -= nonPaintableAttrs  # omit attrs explicitly listed to omit
        if cmds.nodeType(shader) in shaderTypesWithDisplacement:
            paintableAttrs.add('displacement')
        shaderPaintableAttrs.append(paintableAttrs)
    
    # Determine attrs common to all selected shaders
    if len(shaderPaintableAttrs) > 0:
        commonPaintableAttrs = set.intersection(*shaderPaintableAttrs)
    else:
        commonPaintableAttrs = ''
        
    return commonPaintableAttrs
Ejemplo n.º 8
0
def get_node_attributes_info(node_type):
    """
    Retrieve information about about a registered attribute as a dict.

    :param str node_type: The type of the node being inspect
    :return: An object dict
    :rtype: dict
    """
    result = {}

    try:
        attributes = cmds.attributeInfo(allAttributes=True, type=node_type)
    except RuntimeError as error:  # TODO: Document why this can happen
        _LOG.warning(error)
        return result

    return {
        attribute: get_attribute_info(node_type, attribute)
        for attribute in attributes
    }
Ejemplo n.º 9
0
 def get_attribute_shader(self,render_node):
     attr_dic = {}
     all_attr = mc.attributeInfo(all=True,type=render_node)
     for i in ignore_value:
         all_attr.remove(i)
     return all_attr
Ejemplo n.º 10
0
 def get_attribute_shader(self,render_node):
 	attr_dic = {}
 	all_attr = mc.attributeInfo(all=True,type=render_node)
 	return all_attr
Ejemplo n.º 11
0
"""get arnold attributes!"""
import maya.cmds as cmds
sn = cmds.attributeInfo( inherited=False, short=True, type="aiAOVDriver" )
for s in sn:
    print "defaultArnoldDriver.%s = %s" %( s, cmds.getAttr( "defaultArnoldDriver.%s" % s ) )

# cmds.setAttr("defaultArnoldDriver.ai_translator", "exr", type="string")
Ejemplo n.º 12
0
    def createHand(self,*args):
        #Define/Store variables
        label = mc.textFieldGrp(self.labelField,query=True,text=True)
        control = mc.textFieldButtonGrp(self.cntField,query=True,text=True)

        aimVal = mc.radioButtonGrp(self.aimField,query=True,select=True)
        twistVal = mc.radioButtonGrp(self.twistField,query=True,select=True)
        upVal = mc.radioButtonGrp(self.upField,query=True,select=True)

        #Set aim, twist, up
        aim = ' '
        twist = ' '
        up = ' '

        if aimVal == 1:
            aim = 'X'
        if aimVal == 2:
            aim = 'Y'
        if aimVal == 3:
            aim = 'Z'

        if twistVal == 1:
            twist = 'X'
        if twistVal == 2:
            twist = 'Y'
        if twistVal == 3:
            twist = 'Z'

        if upVal == 1:
            up = 'X'
        if upVal == 2:
            up = 'Y'
        if upVal == 3:
            up = 'Z'

        #Create attributes on control
        mc.select(control,r=True)
        attList = mc.attributeInfo(control,all=True)

        if(label not in attList):
            try:
                mc.addAttr(longName=label,k=True)
                mc.setAttr(control + '.' + label, lock=True)
            except:
                pass #Attribute already exists

        for (nameFld,startJntFld,endJntFld) in zip(self.attNameFlds,self.startFlds,self.endFlds):
            attList = mc.attributeInfo(control,all=True)

            name = mc.textFieldGrp(nameFld,query=True,text=True)
            startJnt = mc.textFieldButtonGrp(startJntFld,query=True,text=True)
            endJnt = mc.textFieldButtonGrp(endJntFld,query=True,text=True)


            #Get full chain for each
            chain = []

            #Get the hierarchy of start1, then store it until end1 is found, etc...
            try:
                mc.select(startJnt,r=True,hi=True)
                sel = mc.ls(sl=True,fl=True,type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Adding Curl atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_curl_' + str(x+1), k=True)
                x = x + 1

            #Adding spread atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_spread_' + str(x+1), k=True)
                x = x + 1

            #Twist
            x= 0 
            while x < len(chain):            
                mc.addAttr(control, longName=name + '_twist_' + str(x+1), k=True)
                x = x + 1

            #Connect attributes to joint rotate's ( aim = curl, up = spread )
            x = 0
            try:
                
                while x < len(chain):
                    mc.connectAttr( control+'.'+name + '_curl_' + str(x+1) , chain[x] + '.rotate' + aim )
                    mc.connectAttr( control+'.'+name + '_spread_' + str(x+1), chain[x] + '.rotate' + up )
                    mc.connectAttr( control+'.'+name + '_twist_' + str(x+1), chain[x] + '.rotate' + twist ) 
                    x = x + 1
            except:
                pass
Ejemplo n.º 13
0
    def createHand(self, *args):
        #Define/Store variables
        label = mc.textFieldGrp(self.labelField, query=True, text=True)
        control = mc.textFieldButtonGrp(self.cntField, query=True, text=True)

        aimVal = mc.radioButtonGrp(self.aimField, query=True, select=True)
        twistVal = mc.radioButtonGrp(self.twistField, query=True, select=True)
        upVal = mc.radioButtonGrp(self.upField, query=True, select=True)

        #Set aim, twist, up
        aim = ' '
        twist = ' '
        up = ' '

        if aimVal == 1:
            aim = 'X'
        if aimVal == 2:
            aim = 'Y'
        if aimVal == 3:
            aim = 'Z'

        if twistVal == 1:
            twist = 'X'
        if twistVal == 2:
            twist = 'Y'
        if twistVal == 3:
            twist = 'Z'

        if upVal == 1:
            up = 'X'
        if upVal == 2:
            up = 'Y'
        if upVal == 3:
            up = 'Z'

        #Create attributes on control
        mc.select(control, r=True)
        attList = mc.attributeInfo(control, all=True)

        if (label not in attList):
            try:
                mc.addAttr(longName=label, k=True)
                mc.setAttr(control + '.' + label, lock=True)
            except:
                pass  #Attribute already exists

        for (nameFld, startJntFld, endJntFld) in zip(self.attNameFlds,
                                                     self.startFlds,
                                                     self.endFlds):
            attList = mc.attributeInfo(control, all=True)

            name = mc.textFieldGrp(nameFld, query=True, text=True)
            startJnt = mc.textFieldButtonGrp(startJntFld,
                                             query=True,
                                             text=True)
            endJnt = mc.textFieldButtonGrp(endJntFld, query=True, text=True)

            #Get full chain for each
            chain = []

            #Get the hierarchy of start1, then store it until end1 is found, etc...
            try:
                mc.select(startJnt, r=True, hi=True)
                sel = mc.ls(sl=True, fl=True, type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Adding Curl atts on controller
            x = 0
            while x < len(chain):
                mc.addAttr(control,
                           longName=name + '_curl_' + str(x + 1),
                           k=True)
                x = x + 1

            #Adding spread atts on controller
            x = 0
            while x < len(chain):
                mc.addAttr(control,
                           longName=name + '_spread_' + str(x + 1),
                           k=True)
                x = x + 1

            #Twist
            x = 0
            while x < len(chain):
                mc.addAttr(control,
                           longName=name + '_twist_' + str(x + 1),
                           k=True)
                x = x + 1

            #Connect attributes to joint rotate's ( aim = curl, up = spread )
            x = 0
            try:

                while x < len(chain):
                    mc.connectAttr(
                        control + '.' + name + '_curl_' + str(x + 1),
                        chain[x] + '.rotate' + aim)
                    mc.connectAttr(
                        control + '.' + name + '_spread_' + str(x + 1),
                        chain[x] + '.rotate' + up)
                    mc.connectAttr(
                        control + '.' + name + '_twist_' + str(x + 1),
                        chain[x] + '.rotate' + twist)
                    x = x + 1
            except:
                pass
Ejemplo n.º 14
0
    def create(self,*args):
        #Define/Store variables
        label = mc.textFieldGrp(self.labelField,query=True,text=True)
        control = mc.textFieldButtonGrp(self.cntField,query=True,text=True)
        fkControl = mc.textFieldButtonGrp(self.fkCntField,query=True,text=True)

        aimVal = mc.radioButtonGrp(self.aimField,query=True,select=True)
        twistVal = mc.radioButtonGrp(self.twistField,query=True,select=True)
        upVal = mc.radioButtonGrp(self.upField,query=True,select=True)

        #Set aim, twist, up
        aim = ' '
        twist = ' '
        up = ' '

        if aimVal == 1:
            aim = 'X'
        if aimVal == 2:
            aim = 'Y'
        if aimVal == 3:
            aim = 'Z'

        if twistVal == 1:
            twist = 'X'
        if twistVal == 2:
            twist = 'Y'
        if twistVal == 3:
            twist = 'Z'

        if upVal == 1:
            up = 'X'
        if upVal == 2:
            up = 'Y'
        if upVal == 3:
            up = 'Z'

            #Create main attributes on control
        mc.select(control,r=True)
        attList = mc.attributeInfo(control,all=True)

        if(label not in attList):
            try:
                mc.addAttr(longName=label,k=True)
                mc.setAttr(control + '.' + label, lock=True)
            except:
                pass #Attribute already exists

        #Per limb specified by user
        for (nameFld,startJntFld,endJntFld) in zip(self.attNameFlds,self.startFlds,self.endFlds):
            #Get data for current limb
            name = mc.textFieldGrp(nameFld,query=True,text=True)
            startJnt = mc.textFieldButtonGrp(startJntFld,query=True,text=True)
            endJnt = mc.textFieldButtonGrp(endJntFld,query=True,text=True)

            #Get full chain
            chain = []

            #Get the hierarchy of startJnt, then store it until endJnt is found
            try:
                mc.select(startJnt,r=True,hi=True)
                sel = mc.ls(sl=True,fl=True,type='joint')
                tempChain = sel

                for each in tempChain:
                    if each == endJnt:
                        chain.append(each)
                        break
                    else:
                        chain.append(each)
            except:
                pass

            #Store parent of chain
            parent = mc.listRelatives(chain[0],parent=True)

            #Unparent joints
            for each in chain:
                try:
                    mc.parent(each,w=True)
                except:
                    pass

            #Create duplicate joints above orig joints, then store duplicate joint names
            dupJoints = []
            for joint in chain:
                offName = joint + '_off'
                jnt = mc.duplicate(joint,rr=True,po=True,n=offName)
                dupJoints.append(jnt)

            #Rebuild heirarchy
            x = 0
            while x < len(chain):
                mc.parent(chain[x],dupJoints[x])
                if x != 0:
                    mc.parent(dupJoints[x],chain[x-1])
                x = x + 1

            #Adding Curl atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_curl_' + str(x+1),k=True)
                x = x + 1

            #Adding spread atts on controller
            x= 0 
            while x < len(chain):
                mc.addAttr(control, longName=name + '_spread_' + str(x+1),k=True)
                x = x + 1

            #Twist
            mc.addAttr(control, longName=name + '_Twist',k=True)

            #Connect attributes to dupJoints rotate's ( aim = curl, up = spread )
            x = 0
            #try:
            mc.connectAttr( control + '.' + name + '_Twist' , str(dupJoints[x][0]) + '.rotate' + twist ) 
            while x < len(chain):
                mc.connectAttr( control + '.' + name + '_curl_' + str(x+1) , str(dupJoints[x][0]) + '.rotate' + aim )
                mc.connectAttr( control + '.' + name + '_spread_' + str(x+1), str(dupJoints[x][0]) + '.rotate' + up )
                x = x + 1
            #except:
            #	pass

            #Create fk controllers on joints
            #Duplicate FK control, parent it to chain joints, delete left over transform node
            for each in chain:
                #Duplicate control
                tempCnt = mc.duplicate(fkControl)
                #Select the shape
                tempShp = mc.pickWalk(tempCnt,direction='down')
                mc.parent(tempShp,each,r=True,s=True)
                mc.delete(tempCnt)

            #reparent chain to parent
            mc.parent(dupJoints[0],parent)