• Fernanda

Changing Control Color with PyMEL | Tech Art Bites

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



42 views0 comments

Recent Posts

See All

Tech Art Tomfoolery: Unreal VR and glsl

Happy Tech Art Tuesday! My Youtube Channel has 200 subs now! That means I'm famous! I don't have a tutorial today but I did want to showcase some of the stuff I did this weekend. On Saturday morning I

Be Nice to Non-Gamedev Staff

As I was writing my post on interviews (coming tomorrow), I was reminded of something that bothered me a lot when I joined the industry on-site in 2018. I'd like to introduce the topic with a short st