Created
July 28, 2017 15:10
-
-
Save manhha00/fa8c487a34063749f904bfa6a9128379 to your computer and use it in GitHub Desktop.
scripJob - scriptNode: create a expression, add an attr to object, change color via fun in expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myCode = ''' | |
from maya import cmds | |
def test(): | |
print 'ok' | |
sel = cmds.ls(sl=True) | |
obj_attr = '%s.color' % sel[0] | |
colorNum = cmds.getAttr( obj_attr ) | |
if cmds.getAttr(obj_attr) == 0 : | |
cmds.polyColorPerVertex(r=0.0,g=1.0,b=0.0,a=1,cdo=True) | |
print '%s bang 0' % obj_attr | |
elif cmds.getAttr(obj_attr) == 1 : | |
cmds.polyColorPerVertex(r=0.0,g=0.0,b=1.0,a=1,cdo=True) | |
print '%s bang 1' % obj_attr | |
elif cmds.getAttr(obj_attr) == 2 : | |
cmds.polyColorPerVertex(r=1.0,g=0.0,b=1.0,a=1,cdo=True) | |
print '%s bang 2' % obj_attr | |
cmds.scriptJob ( attributeChange = ['pCube1.color', test]) | |
''' | |
cmds.scriptNode( st=2, bs=myCode.replace("'''","''" ), n='sn_colorChange', stp='python') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment