Created
October 16, 2013 23:53
-
-
Save bengolder/7017012 to your computer and use it in GitHub Desktop.
bake some geometry from Grasshopper to Rhino using random colors for layers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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