Last active
November 4, 2015 22:15
-
-
Save StepMaher/62ce9a82aeff21ad4d85 to your computer and use it in GitHub Desktop.
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
""" | |
Creates a data tree from a list. | |
Inputs: list: List to make a tree. | |
Outputs: tree: Output tree. | |
""" | |
# Name component | |
ghenv.Component.Name = "List to Data Tree" | |
ghenv.Component.NickName = 'ListTree' | |
# Import libraries and methods | |
from Grasshopper.Kernel.Data import GH_Path | |
from Grasshopper import DataTree | |
newTree = DataTree[object]() # Declare new DataTree | |
for i in range(len(list)): # Iterate items in list | |
item = x=list[i] | |
path = GH_Path(0,i) # Explicity construct path for each branch | |
newTree.AddRange([item], path) # Adds a list to the DataTree with specified path | |
tree = newTree # Associate with output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment