Best way to add a color [ ARGB ] when you create a Layer?

May I ask, in Python, what is the best way to create a new layer, and add a color, when you know the RGB number for the color…

Thanks

Andres

Hi Andres, below is one way to do it:

import rhinoscriptsyntax as rs
from System.Drawing import Color

def AddLayerWithColor():
    
    my_color = Color.FromArgb(210,105,30)
    layer_name = "MyNewLayer"
    
    if not rs.IsLayer(layer_name):
        rs.AddLayer(layer_name, my_color, visible=True, locked=False)
    else:
        print "Layer does already exist"
    
if __name__=="__main__":
    AddLayerWithColor()
    

c.

Actually AddLayer() calls rhutil.coercecolor() internally, so you can also just pass a tuple of 3 numbers (R,G,B)…

rs.AddLayer("my_new_layer", (210,105,30))

–Mitch

Thanks so much

I will try that tuple this afternoon

Andres