userdefined_colors_thumb

User Defined Colors

Maya has a feature called User Defined Colors which I’ve found handy for rigging. Basically they are eight colors definable by the user. They are used for nothing in Maya leaving them available for whatever you might need.

userdefined_colors

User Defined Colors

Typically these colors are set via the Color Settings window, but they can also be set through code with the¬†displayRGBColor()¬†command. All you need to do is pass in the name of the user defined color attribute and the RGB values you want. The name of these attributes are “userDefined” followed by a number which can be 1-8. For example – “userDefined1.”

Here is a function for setting a user defined color.

To get a user defined color all you need to do is query that color by name. Here’s a function that returns all the user defined colors and their RGB or HSV values.

And finally, here’s a little function converts a 0-255 based RGB value into 0-1 based value. This is particularly useful since Maya expects 0-1 based RGBs.