Grasshopper Python - BrachCount

I’m trying to script ‘BranchCount’ but it’s not working, what am I doing wrong?
I am not able to count the branches and return 0, 1, 2. Later on I want also to get the branches printed including the items like in Grasshopper is shown in a panel.

DataTree Class
Grasshopper data trees and Python

20180920 00 problem branch (4.3 KB)

Your c variable is simply a nested Python list, not a Grasshopper DataTree.

1 Like

I found a former post of yours which relates to my question.

That one helped me a lot.

I have a question about workflows. People do not usually work in Python with ‘braches and trees,’ people only use it for input or output translations. Is that correct?

Yes, or at least that’s how I usually go about things (and recommend to others) i.e. to decouple the core classes/functions/code within a GHPython component entirely from the Grasshopper API (implementing usually just RhinoCommon.Geometry), and then wrap the output data in the appropriate Grasshopper.Kernel.Types (if outputting a lot of data) and in a DataTree where appropriate/needed. Giulio even added his read/write DataTree functions to GHPython in Rhino 6 for the latter.