Skip to content

Instantly share code, notes, and snippets.

@bengolder
Last active January 29, 2021 13:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengolder/1974640 to your computer and use it in GitHub Desktop.
Save bengolder/1974640 to your computer and use it in GitHub Desktop.
Make DataTree with Python in Grasshopper
import Rhino
import scriptcontext
# for accesssing GH classes
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
# make a DataTree and declare the data type it contains
geometryTree = DataTree[object]()
for i in range(len(points)):
point = points[i]
# make a path for each branch you want to create
path = GH_Path(i)
# this next line adds a list (I create a list of one point)
# to the DataTree using AddRange()
geometryTree.AddRange([point], path)
# you could also use Add() to add a single item to a path
a = geometryTree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment