Skip to content

Instantly share code, notes, and snippets.

@bengolder
Created Oct 16, 2013
Embed
What would you like to do?
bake some geometry from Grasshopper to Rhino using random colors for layers
from Rhino.RhinoDoc import ActiveDoc as doc
from System.Drawing import Color
import random
import Rhino
def makeLayer(name):
idx = doc.Layers.Find(name, True)
if idx == -1:
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
color = Color.FromArgb(r, g, b)
idx = doc.Layers.Add(name, color)
return idx
def layerAtts(name):
atts = Rhino.DocObjects.ObjectAttributes()
atts.LayerIndex = makeLayer(name)
return atts
if layer and geometry and bake:
atts = layerAtts(layer)
for geom in geometry:
doc.Objects.Add(geom, atts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment