maya给模型以及子节点随机染色
import random import maya.cmds as py def material1(): sel=py.ls(sl=True) if sel!=[]: for obj in sel: myShade = py.shadingNode('lambert', asShader=True) #print myShade myShadeSG=py.sets( renderable=True,noSurfaceShader=True, name=(myShade+"SG")) py.connectAttr ((myShade+".outColor"),(myShadeSG+".surfaceShader")) print obj py.select(obj) py.sets (forceElement=myShadeSG) colorR1=random.random() colorG1=random.random() colorB1=random.random() py.setAttr ((myShade+".color"),colorR1,colorG1,colorB1,type="double3" ) else: py.inViewMessage( amg='please select object!', pos='midCenter', fade=True ) material1()
#######################
标签:py,maya,myShade,染色,random,sel,True,节点 From: https://www.cnblogs.com/herd/p/18106430