1.)
What is the correct way to access the individual elements (like the green marked 11.4 in this example)? I tried tree_to_list from treehelpers, but for some reason, although I can access the {0;x} elements, I cannot access the {1;x} elements.
Shoould be really easy… for someone who knows how to do it.
2.)
How can I check programmatically that there is {0;x} and {1;x} but no {2;x} ?
3.)
Is there an article / video you could recommend to better understand the topic? I already watched some videos about data trees, but when it comes to the details, I am still lost.
import ghpythonlib.treehelpers as th
import Grasshopper.Kernel.Data.GH_Path as gp
print x.BranchCount # 8
print len(x.Branch(0)) # 6
print x.DataCount # 48 = 8 x 6
print x.Branch(3)[1].X
print x.Branch(5)[1].X
print x.Path(0)
path = gp(1,0)
print x.PathExists(path)
for i in x.Paths:
if i[0]==1: print i
Thanks @Adam_M that works nicely and has everything I need to continue!
Therefore I marked your answer as the solution.
One thing was missing, so in case anyone out there now wants to know how to access the red marked “13.5” from my initial post - it is now pretty easy (based on the solution):
Thanks @inno for showing this solution. I tried it and it works perfectly as well. So now I have two different solutions that both work properly. Unfortunately I can only mark one as the solution. But yours is one as well.