If you want to output in data tree format, you need to load the library and do some processing.
Please read below.
import System
import Grasshopper.Kernel.Data.GH_Path as GH_Path
import Grasshopper.DataTree as DataTree
This time, we will create a tree by extracting one data from the list data of [3, 4, 6, 7].
list = [3, 4, 6, 7]
tree = DataTree[System.Object]()
for i in range(len(list)):
path = GH_Path(0, i)
val = list[i]
tree.Add(val, path)
a = tree
First, create a tree object to store the data. Any path can be created by using GH_Path (○○) for the path of the data tree. Add those data to the tree one by one using Add and you're done.
It's easy once you remember it. It's a good idea to remember the above operations because you use them often. By the way, the output data tree is as follows.
Recommended Posts