Fernanda
Changing Control Color with PyMEL
Updated: May 21, 2021
Ever tried changing control color through code in Maya? It's specially useful when writing an autorigger!
You can change the color of the curve through the .overrideColor attribute of nurbsCurves.
The attribute is set with integers that correspond to colors in Maya:
colorList = {"BLACK" : 1, "GREY" : 3, "DARK RED" : 4, "DARK BLUE" : 5, "BLUE" : 6, "DARK GREEN" : 7, "DARK PURPLE" : 8, "HOT PINK" : 9, "BROWN" : 10, "DARK BROWN" : 11, "BRIGHT RED" : 13, "NEON GREEN" : 14, "NAVY BLUE" : 15, "WHITE" : 16, "YELLOW" : 17, "LIGHT BLUE" : 18, "TURQUOISE" : 19, "LIGHT BROWN" : 21, "PURPLE" : 30}
curv = [control curve]
# grab the shape node with pickWalk(direction = "down")
curvShape = pm.pickWalk(curv, direction = "down", type = "nodes") [0]
pm.setAttr(str(curvShape) + ".overrideEnabled", 1)
pm.setAttr(str(curvShape) + ".overrideColor", colorList[color])
I usually have this as a staticmethod inside a class. The curv can be whatever curve the user has selected at the time the function is called.
Hope this helps!
-Fernanda