Maya Change Curve Color Python Script

377 views
Skip to first unread message

Sachendra Shukla

unread,
Oct 23, 2019, 11:06:36 PM10/23/19
to Python Programming for Autodesk Maya
Hi All,

I am a Rigging Artist. a few months ago I start to learn the python language. from youtube and then  i wite my first python script "Controller Creator" here is link -- https://www.highend3d.com/maya/script/controller-creator-for-maya 
in this script, you can create 16 different types of nurbs curve shapes in on click.

and now I move forward to add a new option in the script to change curve color. so I write code for that but it's hard for me and I can't change curve color. can anyone tell me how to command execute and it will change the curve color
I send you my script in the attachment you can download and fix the problem.

Thank you 
Sachendra
curve_color.py

ajr...@gmail.com

unread,
Jun 25, 2020, 11:25:04 PM6/25/20
to Python Programming for Autodesk Maya
Sachendra, 

You can set and turn on RGB overrides on any object. Please see below

# Get selection
curves = maya.cmds.ls(selection=True)

# RGB Values
R = 0.0
G = 0.2
B = 1.0

for curve in curves:
    # Trun on overrides
    maya.cmds.setAttr(curve + ".overrideEnabled", 1)
    # Enable RGB
    maya.cmds.setAttr(curve + ".overrideRGBColors",1)
    # Set RGB Value
    maya.cmds.setAttr(curve + ".overrideColorRGB", R ,G ,B)

Hope this helps, 

Adam B. 

Sachendra Shukla

unread,
Jul 5, 2020, 6:18:16 AM7/5/20
to python_in...@googlegroups.com
Hi Adam,

Thank You so much,
Your code definitely helps me. Now I create a window for that. there we can choose color and change.

Thanks 
Sachendra 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6d56ea38-23c7-4c94-a202-566d6363cf51o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages