Skip to content

Instantly share code, notes, and snippets.

Last active Jan 29, 2021
What would you like to do?
Make DataTree with Python in Grasshopper
import Rhino
import scriptcontext
# for accesssing GH classes
import clr
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