Alternative to renumber paths


I’m looking for an alternative way to solve this, that doesn’t involve changing the default behaviour of the Branch component (which is maintain paths).

As an example we have this tree with numbers (1)
Now I’d like to create a new tree and repeat certain branches and omit others (2)
The output I am looking for is the green one (3)

What if I can’t use renumber paths (because this will be done in Beegraphy and it’s not an option).
The only way I could think of was partitioning the output from the branch component, and sometimes that works but in this example it doesn’t (4)
(It would have worked if I wanted branch 1 three times and then branch 3 at the end).

I really can’t think of a way, but hopefully I’ve understood the problem enough to make it clear.
Hoping that someone is on vacation and needs a brain teaser.
renumber_paths.gh (26.6 KB)

Well, this is really not pretty, but I do know that I will always want 3 items in every branch.

But it would be terrible if I sometimes had 3 branches and sometimes 40 branches.

If I’ve understood it right, you want to have a tree which consists of branches (3,3,3,1) without renumbering?

The path index is essentially an address, so if you had 3 branches with the index “3” they are all pointing to the same location - seems impossible, you either have 9 values at index 3 (which you have already), or you subdivide your main branch into {3;0}{3;1} and {3;2}?

I do want renumbering.
The most straightforward way is to let the branch component do the renumbering.
So the output in the green panel IS what I want.
But I’m looking for another way to achieve it.

Oh I see, bit of a kerfuffle then - I’m sure there’s a vanilla way to do it, but my mind kept reaching for TreeBranch no matter what - so instead, here is BranchGrab - it makes a tree from an existing tree and a list of indices for which branches to select - have fun!


Branch Grab.gh (13.3 KB)

Add this to your User Objects folder for future use (it will be placed in the Util container in the Params tab)
Branch Grab.ghuser (4.1 KB)

-Sash

one weird approach would be to zip each branch into a single item, and just List Item on those, then somehow unzip your stuff into branches

it could be easily done with plugins, for instance Metahopper Wrap / UnWrap List: as far as I know it’s able to “group” any GH data together into a single Wrapped thing (in this case you would use that on each Branch of your starting tree)

if you have non-geometry you might go with Text Join / Split Text using the very same separator (take care of not using a character that is present in your texts) this is on the top of the attached example

otherwise if you are dealing with geometries you might go with Group / Ungroup ? (this is on the bottom of the attached example)

renumber_paths_List_Item.gh (15.0 KB)

Thank you, it is for geometry so I’ll check group/ungroup first thing tomorrow.

Thank you, I will check it first thing tomorrow.

That was a good name - branchgrab

It throws errors in Rhino 8

But thanks anyway

The Group/Ungroup approach was great!

Just checked in beegraphy.com and unfortunately they don’t have those nodes so I need to find something else.

Oh, my apologies - I was surprised it didn’t break on my machine when I capitalised the inputs, I thought I’d gotten away with it, this one should play better
Branch Grab.ghuser (4.2 KB)

Here’s another approach, using Tree Item. I replaced the initial number creation with a series and partition list to verify the solution also works correctly with different list lengths.

renumber_paths_Tree_Item.gh (19.7 KB)

5 Likes

Thank you so much. This does the trick.

1 Like

Thank you, thank you, thank you.

I have just tried it with the actual geometry and it works!

Will go to beegraphy.com right away and see if it works there too.

Edit: it does!

2 Likes