Hi, I am very pleased to hear about the implementation of the ‘ghpythonlib’ library into Serengeti’s ghPython.
Nevertheless, I have some issues trying to understand how it works.
When I create a nested list within ghPython, I get the normal > IronPython.Runtime.List; however, when I run the below code, the output is not updated as a a tree with branches
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import ghpythonlib as gh
a = []
result = list(map(list, (pts0, pts1)))
gh.treehelpers.list_to_tree(result)
a.append(result)
print result
Incidentally, the old way works, but I’d like to get around this extra coding.
import rhinoscriptsyntax as rs
import clr
clr.AddReference("Grasshopper")
import Grasshopper as gh
#input list weaving into nested sublists
result = list(map(list, zip(pts0, pts1)))
def pythonListTGhDataTree(someList):
dataTree = gh.DataTree[object]()
for i,l in enumerate(someList):
for v in l:
dataTree.Add(v,gh.Kernel.Data.GH_Path(i))
return dataTree
a = pythonListTGhDataTree(result)
pythonTestingSerengeti.gh (6.8 KB)