Consolidating Paths of Consecutive Path Integer

Hi,
I’m struggling with a data tree issue in Grasshopper, and I can’t seem to get the structure right…
I have a tree of planes organized in branches with single-level paths like:
{0} {1} {3} {4} {5} {7} {8}…
Each branch contains several planes.
What I want to do:
Detect branches with consecutive path numbers (for example {0} and {1}; {3},{4},{5} and so on).
Group those consecutive branches together. So the structure should become something like:
{0} → former {0},{1}
{1} → former {3},{4},{5}
{2} → former {7},{8}
I managed to extract branch indices using Deconstruct Path
Detect consecutive numbers
Create group indices (like 1,1,2,2,2,3,3)
But I get stuck when trying to properly rebuild the tree so that the grouped branches are merged into new paths.

Any help appreciated!

Best,
Vince

Pathgrouping.gh (14.9 KB)

This is solved pretty simply with Member Index


Pathgrouping_solved.gh (17.5 KB)

1 Like

There are easier ways to do this, but continuing on from what the OP had started, and you continued to do:

Pathgrouping VR 01.gh (14.6 KB)

Replace Paths has never been intuitive to me so I tend to partition lists manually-

Pathgrouping_solved2.gh (25.1 KB)

(edit: forgot to flatten at the list partition size)

The common way to approach this is with Relative Differences:


Pathgrouping VR 02.gh (12.4 KB)

using Partition List, as you prefer.

2 Likes