C# -- How to add empty branch in DataTree<Point3d>?

Ok, so I encountered a nasty problem with a DataTree when counting Items (using ListLength) which didn’t return = 0 for branches with zero items simply because my C# code didn’t add any items to a Branch when there weren’t any items, meaning the Branch itself was missing.

And since ListLength cant detect a missing branch, it couldn’t return the value = 0 items for that Branch index, meaning that some of my lists end up helplessly out of sync.

== Question ==
Can I somehow add a Branch (with C# code) without adding any items to it? In this case DataList ? (and same thing with GH_Structure)

And if empty Branches can be added in code, then my next question is if the ListLength will then return = 0 for the empty Branch(es), or will it go bananas?

// Rolf

DataTree_Empty_V1.gh (4.6 KB)

Add a few lines for some random variable dimensions paths (use stuff the likes of dimMin, dimMax) and/or randomly populate some paths

1 Like

Hi Peter,

That was very elegant Peter, thank you for the example. Works like a charm.

Have a nice weekend.

// Rolf