@piac
I thought I found this great function that formats the data tree to Python but it truncates the result. Any idea why?
TreeHelper.gh (3.4 KB)
@piac
I thought I found this great function that formats the data tree to Python but it truncates the result. Any idea why?
TreeHelper.gh (3.4 KB)
when you type “(” just after th.tree_to_list, it will show you this helper:
tree_to_list(input, retrieve_base=lambda x: x[0])
Returns a list representation of a Grasshopper DataTree.
Inputs:
input: A tree to be transformed.
retrieve_base= lambda x: x[0]:
Most trees start with a [0] path that is never changed.
That is rendered as a list with a single item. However, for simplicity, most users
will want to start using the first branch in that path. Therefore, retrieve_base
defaults to a function that will just return the first item in the output.
If a tree is created manually or edited,
then it can also have paths starting with [1] etc. In this case, retrieve_base can
be set to None. In this case, the entire result is returned, inside a single list.
This is the equivalent of the "source" input for list_to_tree.
Returns:
A list object
you can use th.list_to_tree(x, None)
to get what you are looking for:
Got it. Thanks!