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?
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
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)