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)
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!
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)
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.