How to provide a parent branch list to all its sub-branches?

Hi everyone,

I’m struggling with a data tree matching issue. I have two trees with different path depths and I want to perform an operation between them. For simplicity i picked addition as seen below.


Setup:

The parent tree has a depth of 1 (e.g., {0}, {1}) containing lists of values (e.g., 10, 20, 30).

The children tree has a depth of 2 (e.g., {0;0}, {0;1}, {0;2}) containing single indices.


Problem:

Grasshopper seems to match the branches based on their index order, not their path name.

Branch {0;0} matches with {0}, so far so good.

Branch {0;1} matches with {1} instead of staying with {0}

Once the a tree runs out of branches, all subsequent branches of the other tree reuse the last branch of the first one.


Goal:

I want every sub-branch that starts with 0;... to use the data from parent branch {0}, and every sub-branch starting with 1;... to use data from {1}. Essentially, I need the parent list to be duplicated for each of its children. I can imagine this as a workaround but there has to be a smart and dynamic solution to this.

So I have tried Path Mapper and Match Tree, but I can’t seem to get a hold to it.
Appreciate any input and help to this.


Attachments:


branchxreference.gh (10.8 KB)

PS: You should avoid piping data through Panels because they cast incoming data to strings. This works with integers because they can be re-cast back from strings with no loss. Anything more complex, like meshes or surfaces, will break. Even passing floats through will lose precision.

Thank you for the excellent solution!

Alltough, I now realize I should have been more specific from the start (100% my mistake). While Cross-Referencing works for small abstract sets, my actual goal is much more data-intensive.

The ultimate goal is to average points with the same X-value across multiple lists, creating one reference curve.

Skip to the TLDR Question.


Setup:
I have multiple lists of points organized in a tree (Branches {0}, {1}, etc.).

Within each branch, I use Create Set and Member Index to group points by their X-coordinate.

This creates a sub-branch structure like {0;0}, {0;1} (for X=1, X=2 in the first list) and {1;0}, {1;1} (for the second list).


Problem:

I need to use List Item to retrieve the actual point data using the indices from Member Index. However, the indices in {0;n} must only ‘go shopping’ in the point list of parent branch {0}.

If I use a standard List Item, Grasshopper’s default matching fails because it aligns the 2nd branch of the indices {0;1} with the 2nd branch of the points {1}. Cross-referencing here would be extremely inefficient due to the number of points.


Question (TLDR):

How can I ‘re-align’ or ‘inflate’ the parent point tree so that every sub-branch {N;i} has a direct 1-to-1 partner branch containing the points from {N}?

I am looking for a dynamic solution that scales with the number of X-coordinate sets and ensures that the result tree is organized exactly like the Member Index tree, but filled with the actual point data.

I attached the grasshopper files this time.
Thank you for your patience.


Attachments:


matchPoints.gh (35.3 KB)

If you want a fast an black box solution, Treesloth plugin has “propagate ancestor” component that does exactly this

:smiley: - Often the way! I’ll take a look at your real data…
EDIT: Unless you’re happy to use a plugin, in which case I’ll save my time!

Will try plugin first.
No need to reinvent the wheel!

Worked like a charm, will never work without it anymore.

Thank you everyone!

Sometimes it’s worth to reinvent the wheel (or at least taking a look at it), to get a deeper understanding of how things works.

If you want here is somethin else: branchxreference.gh (13.3 KB)

Actually, I came up with my own workaround before discovering treesloth.

I still prefer my cluster most of the times since prop ancestor grafts the inputs, even when I don’t need it (in my first response I wasn’t at PC so I just shared a blue pill - have fun down the rabbithole)

“Z-trick” liebster,

lange nichts mehr gehört. Ich habe einen Auflauf gebacken. Schau doch mal vorbei.


matchPoints VR 03.gh (108.5 KB)