Partition in python

Hi guys!
I’ve written a complex python script for a grasshopper definition whose output is a quite large number of points. I’d like to output this as a specific datatree. I already created the tree with its branches using the partition component. Does anyone have an idea how I could implement the datatree output within the python script?
I’ve already tried some list-of-list approaches, but I couldn’t transform them into the corresponding datatree.
Thanks for your help.

from ghpythonlib import treehelpers

nested_list = [[0, 1, 2], ["apples", "peaches", "eggplant"], [0.78, 25.0, 0.001]]

# Converts a nested list to a Grasshopper tree
tree = treehelpers.list_to_tree(nested_list)

# Converts a Grasshopper tree back to a nested list
nested_list = treehelpers.tree_to_list(tree)

In addition to the already provided example, here are a 2 examples of how to prepare nested lists, in python, for use with the treehelper function.
the first is a simple for loop that copies a whole list, into a “Master List”.
the second is kind of like a generator function in python, except it is copying the partitions into a master list.
Note, I just realized I am in Rhino WIP, I imagine they would also work in 6.

1 Like