How to make a Color from rhinoinside using Python

I am converting a bunch of code from RhinoScriptSyntax to RhinoCommon. So far, I have been able to use the source code RhinoScriptSyntax to figure out where to look in RhinoCommon. Suddenly, I ran into a problem.

It seems that the Color property of a Layer (for example) comes from a System module. I think this is a C# module but I am using Python. Is there a way to create (and get values from) a Color using some method in RhinoCommon? Where do I go from here?

Here is a snip of where I am at…

import rhinoinside
rhinoinside.load()
import Rhino
document = Rhino.RhinoDoc.CreateHeadless(None)

someLayer = document.Layers.FindName(‘Bob’)
color = someLayer.Color

Now what do I do with this .NET object?

I hope this makes sense - It is getting late.

Thank you for your help.

Hi @Henry_Wede

Its a Tuble of Values.

import Rhino

doc = Rhino.RhinoDoc.ActiveDoc

layer = doc.Layers.FindName('test')

color = layer.Color

A = color.A
R = color.R
G = color.G
B = color.B

print A,R,G,B

Here is the link

1 Like

Thank you. I looked at the System.Drawing.Color documentation before but didn’t realize that Rhino somehow makes the System module available. I suppose that I should have just tried it.

For the record, this works from a command prompt:

import rhinoinside
rhinoinside.load()
import Rhino
import System

document = Rhino.RhinoDoc.CreateHeadless(None)

for layer in document.Layers:
    print(f’{layer.Name} \t {layer.Color=}')

newColor = System.Drawing.Color.FromArgb(255, 200, 0, 0)
print(newColor)