Skip to content

Instantly share code, notes, and snippets.

@sbaer
Forked from bengolder/gist:1019295
Created June 14, 2011 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbaer/1025541 to your computer and use it in GitHub Desktop.
Save sbaer/1025541 to your computer and use it in GitHub Desktop.
Grasshopper File and Geometry Import Script
import Rhino
# read geometry out of 3dm files and filter by layernames
if DoImport and FilePaths and LayerNames:
geometry = []
for filepath in FilePaths:
model = Rhino.FileIO.File3dm.Read(filepath)
if not model: continue
for layer in LayerNames:
objs = model.Objects.FindByLayer(layer)
for obj in objs:
geom = obj.Geometry
geom.EnsurePrivateCopy()
geometry.append(geom)
# models can take up a considerable amount of
# memory that we don't need, so get rid of it
# after copying the geometry we want out of it
model.Dispose()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment