Last active
January 29, 2021 13:24
-
-
Save bengolder/1974640 to your computer and use it in GitHub Desktop.
Make DataTree with Python in Grasshopper
This file contains hidden or 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
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