Ability to randomise the colour of newly created layers instead of the default black

Ability to randomise the colour of newly created layers instead of the default black

Video explanation

1 Like

Here is an example straight out of the Rhino Python help file. It doesn’t randomize upon creation but does randomize the layer colours that exist.


import rhinoscriptsyntax as rs
import random
from System.Drawing import Color
       
def randomcolor():
    red = int(255*random.random())
    green = int(255*random.random())
    blue = int(255*random.random())
    return Color.FromArgb(red,green,blue)
       
layerNames = rs.LayerNames()
if layerNames:
    for name in layerNames: rs.LayerColor(name, randomcolor())

Maybe this will help. I think your idea about randomizing colours on layer creation would be a nice option.

Thanks,

Dan

Hi - I’ve added this thread to the existing RH-4978.
Thanks,
-wim

Hi Dan :slight_smile:

When running this script, it randomises the colours of all layers. Is it possible to randomise the colours of only the layers selected?

-Jeremy

Here’s one that allows you to randomize the color of selected layers.

RandomColorSelLayers.py (541 Bytes)

1 Like

can you guide me how to use this file in Rhino?

Here is the complete guide:
https://wiki.mcneel.com/rhino/macroscriptsetup