Partitioning a data tree of numbers with partition list

I am trying to take a data tree and and move every N branches into a new branch. So for example if the tree has 100 branches, I’d like to put every 10 of them into a new branch - resulting in 10 branches of 10 branches. It’s working for lists, but I can’t get it to work for trees.

This is all dynamic so the path mapper won’t work. The background is that I have a component for putting wall panels together. Each panel is a group of sub-panels, each sub panel is a pattern of 1’s and 0’s.

To keep it fast, this is all just numbers, the numbers drive the other part of the component which is geometry.

partition tree problem.gh (13.7 KB)

like this?

2 Likes

Yes, but how can I do this without path mapper? So that the quantity of branches can change based on inputs.

Replace Paths seems to do the trick.

partition tree problem.gh (18.9 KB)

And with Series you can end up with a 2-level tree :

partition tree problem.gh (21.3 KB)

1 Like

With a simplified one-level input tree, you could also replicate the Path Mapper solution above, which gives access to the number of partitions.

partition tree problem.gh (16.5 KB)

2 Likes

in order to solve the input of the branches quantity, I write a C# component.


partition tree problem (2).gh (17.9 KB)

1 Like

Thanks @magicteddy for the multiple solutions, this is the first time I’ve been able to get a grip on ‘replace paths’. Also @Tao_Lin, your C# is astonishingly simple. Thank you both!

Here is the script I used from @magicteddy as applied to the problem:

Also, here is a rebuild of the tree that I ended up doing earlier in the day. Flattening and re-building the tree into a new structure was a little more intuitive than replacing actual paths:

The saved script is attached.
partition tree problem.gh (27.2 KB)