Get path infos datatree c# grasshopper

Hi, let’s say I have a GH Tree {52;47} or {A;B}

is there any method that returns all the paths A ?
like a list of all my paths (0,3,4,8)…
I am asking because in need to identify empty paths to add later on null value instead of "no "paths


HashSet< int > dims = new HashSet< int >();
int dim = 0; // or 1 for sec dimension etc etc
foreach(GH_Path path in tree.Paths) try{dims.Add(path.Indices[dim]);} catch{}

PS: as an option you can detect a “gap” in sequential dims values and EnsurePath(gapValue) for creating an empty path. (or if you are lazy use Ensure up to the max dims value).

Practice with stuff the likes:

1 Like

Ah peter has been faster !
If you’re not familiar with C#, you can also use Deconstruct Path along with Tree Statistics.

Deconstruct (10.4 KB)

Also, if you’re working with empty paths, you might consider using Null Item.

PS : oops, I did not look at post tags, I guess C# answer is what you were looking for

1 Like