Grasshopper Data Tree - Tree Helper - Can't find branch count?

Hi,

I’m trying to code against GH data trees in the Python script node but seem to be misunderstanding accessing branch counts.

In the provided example, I created a basic data tree of numbers -

4 base branches, each with 3 branches, each with 2 items - a total of 24 items.

I was hoping to use Tree Helper to access each branch and the items such that I can code against -

4 Lists, each containing 3 lists, which each contain 2 items.

after using Tree_to_list(), I seem unable to access the base branch count, which would be 0,1,2,3

I expected -

len(aNumbers) = 4
len(aNumbers[0]) = 3
len(aNumbers[0][0])=2

whilst it returns
len(aNumbers) = 3
len(aNumbers[0]) = 2

How do I access the primary branch number?

The Python input has been set to Tree, and object type set to Float.

Thanks

EDIT:

Okay the issue seems to be resolved when I use

aNumbers=th.tree_to_list(aNumbers,None)

But can someone explain what the retrieve_base input is?
In what case would I want retrieve_base to be lambda x:x[0] or whatever else?

Thanks

try: aNumbers = th.tree_to_list(aNumbers, None)

1 Like