Retrieve branches within an existing branch structure

I’m sure I’m not the first one with this problem, but I couldn’t find any other post about it.

I have an existing branch structure and I want to retrieve different branches within it. It’s a topology map so in this case it is self referencing (the paths in each branch reference the branch’s neighbours). I want to retrieve the items in the paths, but don’t loose the actual tree structure. Unfortunately, the component “Tree Branch” will flatten the input and and then sort the branches that it retrieved.

Any ideas? Am I thinking in the wrong way here?

tree branch flattens?? Split Tree is more versatile.

That’s not what I meant.

Let’s look at the branch in my screenshot {0;1;1}. I want the items from branches {1;3;1}, {3;1;0} and {4;3;0} in this branch.
What Tree Branch does, it will actually take those items, but in their original three branches, and then sort them based on their original branches. so basically, it doesn’t do anything.

If you want an item {1;3;1}, {3;1;0} and {4;3;0} in {0;1;1}, they will be flattened when you don’t modify the tree for deeper structure.
As you see in your screenshot, {1;3;1} etc are just written as paths, but are actually items with indices 0,1,2 in the branch {0;1;1}
So the only solution I see is modifying their path if I understand you right.
{1;3;1} => {0;1;1;1;3;1} They are now in a different branch, but you can get them back with path mapper.

Don’t know what you mean.

There are many ways to handle trees, but maybe upload an example, to get the right solution for your problem.

Yes it’s not easy to understand, but I think you might be right in any case.

I have attached a file as an example. There is a tree structure with points in branches, which I basically want to re-shuffle into the branch structure below, or as in the screenshot attached.

retrieve_paths.gh (21.1 KB)

I internalised the points to make it easy to look at.

I managed to achieve the same result by “counting” the indices within the point list and instead of creating a list of branches i created a list of indices (as if the branch structures would just go {0}, {1}, …), and then added that with the amount of points per list.

So, for example, the branch {1;3;1} would actually be index 6 in a flattened tree, and because all branches before that have four pts in them, 6 would become 24, 25, 26, 27. Unnecessarily complex but it worked.

Ok, glad you found a solution.

Downloaded your file and came across some strange behavior. I recreated your list, and get some weird results, I can’t explain to myself. Looks like a bug for me. Or maybe just too late in the night.

Rebuilded the point list with integers for better visualisation. At the top is my “branch path” list. And at the bottom yours. Look the same for me, but with different behavior in tree branch.

retrieve_paths_re.gh (26.6 KB)

Thank you for trying to solve this so late at night. However, I think it’s actually the same result, only less visible in your list. What the Tree Branch component will do (the “bug”) is take the branch paths and output the items in these branches, but with the original branch paths.

The resulting tree will always have the branch structure from the branch paths input in P, not the branch STRUCTURE from the input P’s list. Otherwise, the result of your list would have the structure:

{1;3;0}
24
25
26
27

{0;2;1}
28
29
30
31

and so on…

Ah yeah, definitly to late. :see_no_evil: Forgot to turn of maintain paths…

retrieve_paths_re.gh (26.9 KB)

Hehe, unfortunately that didn’t solve it either. If you replace the points with numbers it becomes more clear that:

  • branch {0;1;1} is being called three times in the list (somewhere further down)
  • it will retrieve the items in this branch, but then put them in said branch {0;1;1}
  • the result is that we have the items of this branch three times.

opps, sorry about that, was running out the door at the time.

Odd data set, probably a few ways to do it though.

retrieve_paths_re2.gh (28.3 KB)

Disregard, its starts out ok then veers off course

He already found a solution :slight_smile:

Thanks for the effort. Well my solution works because I ALSO have the indices sorted in the same structure as the branches in my example file, but i then have to create series through all of the indices and that takes 3 seconds at the moment… so yeah, if someone has a better solution do let me know :slight_smile:

Solved using Elefront (my weapon of choice)

retrieve_paths_re3.gh (30.4 KB)
retrieve_paths_re3.3dm (2.2 MB)

2 Likes