The ghpythonlib.treehelpers.tree_to_list method returns a null value

The ghpythonlib.treehelpers.tree_to_list method returns a null value,I do not know why,Thank you for all the suggestions.

This is my code.
import ghpythonlib.treehelpers as ght

def TreeToList(tree):
    outlist=[list(tree.Branch(i)) for i in tree.Paths]
    return outlist


new_indexs = ght.tree_to_list(index)
print new_indexs

my_indexs = TreeToList(index)
print my_indexs


This is my gh file:
tree_to_list.gh (16.9 KB)

try this:

new_indexs = ght.tree_to_list(index,0)
1 Like

thank you very much.
new_indexs = ght.tree_to_list(index,0)
This will also return some None


But tried this code to solve this problem

Yes, the code i posted will return some None values. I believe your input indexes are not all sequential, (0,1,2,3, etc…). I think you had something like (1,2,3, 7). I’m sure someone else would be able to describe this more accurately, but as I understand it, the tree_to_list function is starting at branch 0, and will create branches with None values in those empty/non-sequential gaps in your input list…Not sure that’s a clear explanation.

1 Like