ghPython Node access data tree objects

How do I access the individual geometry inside of a data tree when it is passed into a python node? I would like to iterate based on the index of the list as expected in normal python code but it does not seem to work. I know how to do this with a bunch of gh nodes but essentially trying to shorten and cleanup the messy nodes and strings by combing whenever possible into a python node. Attached is just a simple example of using lines and the subdivide nodes.

Thanks, any help is appreciated!

more datatree.gh (12.7 KB)

If this is Rhino 6, you can use treehelpers, (added to deal with this situation) Try this in the component that is red in your image. (change the x input to List Access and remove the Flatten from Line Component.).

import rhinoscriptsyntax as rs
import ghpythonlib.treehelpers as th

t = []

for c in x:
     t.append(rs.DivideCurve(c, y))

a = th.list_to_tree(t, False)
2 Likes