Override Color UI Script

Here’s a little script I whipped up that will change the display color of curves, joints, and wireframes to the desired color.

It’s a little frustrating that maya only gives you 32 colors to work with, many of which are dull and low-chroma, but what’re you gonna do.

Here’s the UI:

Here’s the script:

import maya.cmds as cmds

def changeColor(i):
sel = cmds.ls(sl=1,o=1)
for obj in sel:
cmds.setAttr(obj + ".overrideEnabled",1)
cmds.setAttr(obj + ".overrideColor",i)
print ("# cmds.setAttr(\"" + obj + ".overrideColor\", " + str(i) + ")" + "\n")

def colorChangerUI():
if cmds.window("ColorChanger",exists=1):
cmds.deleteUI("ColorChanger")

cmds.window("ColorChanger",tlb=1,t="Custom Color Changer",s=0)
cmds.gridLayout(cw=30,nc=7,nr=3)

cmds.canvas("colorSwatchWhite",rgbValue=(1,1,1),width=20,height=20,pc="changeColor(16)")
cmds.canvas("colorSwatchGrey",rgbValue=(.6,.6,.6),width=20,height=20,pc="changeColor(0)")
cmds.canvas("colorSwatchPink",rgbValue=(1,0,1),width=20,height=20,pc="changeColor(9)")
cmds.canvas("colorSwatchYellow",rgbValue=(1,1,.1),width=20,height=20,pc="changeColor(17)")
cmds.canvas("colorSwatchGreen",rgbValue=(.1,.8,.1),width=20,height=20,pc="changeColor(7)")
cmds.canvas("colorSwatchBlue",rgbValue=(.1,0,.9),width=20,height=20,pc="changeColor(5)")
cmds.canvas("colorSwatchRed",rgbValue=(.8,.1,.1),width=20,height=20,pc="changeColor(13)")
cmds.canvas("colorSwatchTeal",rgbValue=(0,.8,.5),width=20,height=20,pc="changeColor(19)")
cmds.canvas("colorSwatchGreen2",rgbValue=(.1,.6,.3),width=20,height=20,pc="changeColor(23)")
cmds.canvas("colorSwatchRed2",rgbValue=(.7,0,.4),width=20,height=20,pc="changeColor(31)")
cmds.canvas("colorSwatchBrown",rgbValue=(.6,.3,.2),width=20,height=20,pc="changeColor(10)")
cmds.canvas("colorSwatchPurple",rgbValue=(.4,0,.8),width=20,height=20,pc="changeColor(8)")
cmds.canvas("colorSwatchBlack",rgbValue=(0,0,0),width=20,height=20,pc="changeColor(1)")

cmds.showWindow("ColorChanger")
cmds.window("ColorChanger",edit=1,wh=(180,64))

colorChangerUI()

 

 

Advertisements
Image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s