Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """___________________
- colorTinter
- version_2
- cwisbg
- Brandon Gillespie
- 2/1/2012
- ______________________
- """
- from pymel.core import*
- import random as r
- def tinterStg1(a):
- shadingNode('singleShadingSwitch', au=1, n = '{0}_colorSwitch'.format(a))
- shadingNode('ramp', at=1, n = '{0}_ramp'.format(a))
- connectAttr('{0}_colorSwitch.output'.format(a), '{0}_ramp.vCoord'.format(a),f=1)
- try:
- miaDiffuse = listConnections('{0}.diffuse'.format(sl[0]), p=1)
- except:
- miaDiffuse = 0
- try:
- otherColor = listConnections('{0}.color'.format(sl[0]), p=1)
- except:
- otherColor = 0
- if otherColor:
- colorConnections = listConnections('{0}.color'.format(sl[0]),c=1)[0][1]
- connectAttr('{0}_ramp.outColor'.format(a),'{0}.colorGain'.format(colorConnections), f=1)
- elif miaDiffuse:
- colorConnections = listConnections('{0}.diffuse'.format(sl[0]),c=1)[0][1]
- connectAttr('{0}_ramp.outColor'.format(a),'{0}.colorGain'.format(colorConnections), f=1)
- else:
- try:
- connectAttr('{0}_ramp.outColor'.format(a),'{0}.color'.format(sl[0]), f=1)
- print 'there'
- except:
- connectAttr('{0}_ramp.outColor'.format(a),'{0}.diffuse'.format(sl[0]), f=1)
- print 'here'
- def connector(a):
- matShapes = listConnections(sl[0], t='shadingEngine', d=1)
- SG_mesh = listConnections(matShapes[0],t='shape', s=1)
- mesh_shapes = []
- for i in SG_mesh:
- randoC = r.random()
- mesh_shapes.append(listRelatives(i,s=1))
- checkColor = attributeQuery('color',node = i ,ex=1)
- if checkColor:
- print 'Already has color atribute'
- pass
- else:
- addAttr(i, ln = 'color', at='double', min=0, max=1)
- setAttr('{0}.color'.format(i), randoC)
- setAttr('{0}.color'.format(i),e=1, keyable=1)
- x = 1
- z = 0
- for i in mesh_shapes:
- connectAttr('{0}.instObjGroups[0]'.format(i[0]), '{0}_colorSwitch.input[{1}].inShape'.format(a,z))
- z += 1
- z = 0
- meshLength = len(SG_mesh)
- for mesh in SG_mesh:
- connectAttr(mesh+".color",'{0}_colorSwitch.input[{1}].inSingle'.format(a,z),f=1)
- z += 1
- """
- """
- sl = selected()
- tinterStg1(sl[0])
- connector(sl[0])
Advertisement
Add Comment
Please, Sign In to add comment