Match & replace items in a tree

As a follow-up to this topic: Detect geometry changes - access GUID data in between paranthesis?, a brief summary, I need to detect geometry changes as a trigger for further operations in my script.

Now that I have a way to detect geometry changes, I need to, at some point, update the attributes that I use to detect changes. For that, I have two User text components, one that references the values in Rhino and one that contains the recomputed values in Grasshopper. The outputs thereof are simulated with two sets of two data components.

For reference, this is what I am trying to achieve: to replace particular attribute key values in a list:


If I move geometry, the length value changes as well as the Start/ End point position. If I edit a cure’s CV’s, the length changes. If I move a Start/End point, the Start/ End point and the length of a curve change. And I just need to update the attribute keys in the red list.

Because the position of the attribute key may change depending on the geometry, I need to search and match an attribute’s position for both the referenced and recomputed attributes (technically, I can get away using the same indices for both). I use multiple member index components and merge their values to determine the matching indices:

I can then pull the new recomputed values from the top and replace them within the referenced list on the bottom:


This step is important, because I may have made changes to some of the referenced geometry’s attributes in Rhino and want to preserve them.

My question right now is: is there a way to find the indices in parallel? In case I feed in an arbitrary number of attributes that I want to change through Grasshopper, I don’t want to be limited by the number of member index components that I placed on the canvas. So is there an easier way to find multiple items in a branch and get their indices?

20230822_Match replace branches in tree.gh (26.8 KB)

Guess it’s just a matter of data matching for this one, a possible solution:

20230822_Match replace branches in tree_Solution.gh (11.5 KB)