• Fernanda

Changing Control Color with PyMEL

Updated: May 21

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



67 views0 comments

Recent Posts

See All

Fernanda's Maya Shelf (updated 6/7/2021)

Below you'll find the Maya Shelf I've been using to make my workflow a bit faster. You should be able to download it, unzip it, then drag it into the Maya/20XX/prefs/shelves folder, and load it into M