How to find a specific DATA PATH and rearrange the combined data


Suppose I have two data trees. The first is the lower left (A), and the second is the lower right (B). I have to find the data path in the second data tree, which contains a certain value. In this case, the value is shown in the above panel.

So it should give me the output {0,2} in this case. After finding this data path, I need to rearrange the second data tree such that {0,2} will become the {0,0} and previous {0,0} & {0,1} should be added in the last to the same data tree.

Say the second data tree (B) has 7 branches. Now the new branch arrangement should be {0,2},{0,3},{0,4},{0,5},{0,6},{0,0},{0,1}

After this, I need to rearrange the data in an alternate pattern, such that the first data tree’s data should be in an odd place and the second data tree’s data should be in an even place.

Say the first data tree (A) also has 7 branches. Then, the final data should be like

A{0,0}
B{0,2}
A{0,1}
B{0,3}
A{0,2}
B{0,4}
A{0,3}
B{0,5}
A{0,4}
B{0,6}
A{0,5}
B{0,0}
A{0,6}
B{0,1}

It’s really difficult to give help to others without the actual file in hand.
See point 3 here Help Us Help You

(recreating a set of data, 2 datatrees in this case, is bothering enough that make one avoiding trying to help completely…)


This said, you are lucky your data are points!
Use groups.

By using groups you can handle whole branches as single objects, and so you simplify your datatree structure enough and in your case you will just handle simple lists.
Then lastly do ungroup to retrieve your actual sorted datatree.


Do a distance check to your single point, if distance is smaller than 0.001 then you get a “true”.
Do mass addition, the only branch with a “1” will be the branch that had the point.
etc etc
weave list A with list B.
ungroup


EDIT: Not whining or anything, but writing this post of mine require way more time than probably making the actual solution on grasshopper.
If you attached your .gh file with internalized data both of us would have spent less time writing/reading and you could have already a first working solution.

Dear Riccardo,

Sorry for the problem you faced while solving my problem; I’m attaching a gh file.

@DavidRutten
using groups for geometries is really handy for cases where one might not find a quick and easy way to handle data trees and branches.
It would be interesting to have a “group-like” object in grasshopper to “pack” anything.
For example, if the data is text, you can join the texts toghether with a specific character and later splitting the text, but is still tricky.

A “Group” for generic data instead of only geometries would be super.
And the option to make groups of groups too… flattening datatrees when needed, making datatrees a single object!

PS not “groups” as we already have 3 distinct rhino/gh things with that name, but another term maybe.
Condensed? Esiccated?

1 Like

Please find the .gh file here How to find a DATA Path

you said data has 7 branches, but in the attached file -in the other thread- only A is present and has 5 branches :upside_down_face: B is missing?

this should be following the logic you have explained (of course you’ll need to plug the right data in B to see if it works)

finds in which branch of A the given value is
shift the branches of A in such a way the branch containing the given value becomes {0}
weaves branches with tree B, with pattern BABABA…

Joining Two Curves_inno.gh (18.2 KB)

a good idea is also to explain the problem you are trying to solve, instead of the specific way you are trying to solve it, in such a way to get different points of view on the very same matter :+1:

2 Likes

Thank you for the solution. I am working on a big problem and can’t share that file here, so I made a file with five branches, but the problem was the same.