How to get color RGB and not a name like "black"

I try to get material diffuse color as RGB value from the object, but on one object it gives RGB value as numbers and on some gives a name like “black”. I need numbers only, no names.

https://developer.rhino3d.com/api/RhinoScriptSyntax/#material-MaterialColor

I look here but no information on why this happens. Please if somebody knows, advice how to get RGB in numbers. So 0,0,0 is 0,0,0 not “black”.

Hi Qtov,

the color is returned as a System.Drawing.Color object
https://msdn.microsoft.com/en-us/library/system.drawing.color(v=vs.110).aspx

If the color is a predifined named color it will indeed print the name rather than the A R G B values.
to retrieve the RGB values you can get it’s RGB values individually like so:

mcolor = rs.MaterialColor(materialindex)
r = mcolor.R
g = mcolor.G
b = mcolor.B
print r,g,b

Does this help?
-Willem

1 Like

Hello Willem,

Thank you, this works exactly as I needed !

Very great to get such fast reply. Thanks again : )

1 Like