Ghpythonlib.treehelpers.list_to_tree failed in new GH

Hi guys,

I used a python code in GH of Rhino 7 to read point files and export 3d points tree.
In the code, I used the componenet “ghpythonlib.treehelpers.list_to_tree” to transfer nested lists of poits into tree for next steps.
However, when I use the same code in GH of Rhino 8, the output is a list of “Rhino.Collections.Point3dList” which I can’t use in GH.
How can I fix this issue?
Thank you all so much!

Hi @w.wu

Can you cast your Point3dLists into standard Python lists before passing them to the list_to_tree method?

from ghpythonlib import treehelpers as ght
from Rhino.Collections import Point3dList
from Rhino.Geometry import Point3d

l1 = Point3dList()
l1.Add(Point3d(0,0,0))
l1.Add(Point3d(0,0,1))
l1.Add(Point3d(0,0,2))

l2 = Point3dList()
l1.Add(Point3d(0,0,0))
l2.Add(Point3d(0,0,1))
l2.Add(Point3d(0,0,2))

a = ght.list_to_tree(
    [ list(l1), list(l2) ] #<- Cast each Point3dList to standard list
) 

Seems to work.

best of luck,
@ed.p.may

2 Likes

Thank you so much, @ed.p.may, for your kind reply!
Your method works!
Have a nice day! :grinning:

1 Like