Duplicated Tree Unflatten per grafted branch

Hi All,

This is not an easy question. So I hope I explain it well.

I have a tree (51 items in total) of a specific data structure which I had to flatten in order to copy 7 times along different vectors using a series. Now the structure of the new tree consists of 7 branches with each branch containing 51 flattened items. I would like to unflatten each new branch to the structure of the original tree with adding one number at the beginning at each unflattened branch that indicated the number of that item in the copied series (7 copies in this case). For example: if the original tree’s structure is a combination of these branches (1;0) and (2;0), I want the new tree structure for the 7 copies to be {0;1;0}, {1;1;0}, {2;1;0}…{6;1;0}, and {0;2;0}, {1;2;0}, {2;2;0}…{6;2;0}.

I was able to do this by exploding the tree branch consisting of flattened branches (i.e. {0},{1},{2},{3},{4},{5},{6}) then unflattering each tree and entwine them using graft option. Is there an alternative?

I hope the screenshots and description is sufficient, as I can’t share the script. Thanks in advance.

It’s not sufficient, attach a minimal file of your problem, internalize needed values and delete the rest like David shows in the linked topic.

Additionally my wild guess is that this:

is not necessary, but hard to say without a file.

Thanks Daniel, attached is a similar script. question.gh (6.4 KB)

If I understood you correctly you could flatten the planes instead, use partion list + path mapper after.

question_re.gh (8.1 KB)

Thanks Daniel, works perfectly for single item trees.
Mine is not so I grafted the geometry being copied and change the path mapper slightly and it worked.

Much appreciated.

Why not just graft the output of Orient?


That would work. Further cleansing of the try will be required using this option. In my case, if I got for this, I will need to build a path mapper which switches few paths. Thanks Joseph.

Path Mapper is fragile and prone to failure when the upstream data tree changes. I’ve managed to avoid it completely for many years. There are other ways. Shift Paths instead of flatten, Clean Tree and Prune Tree work very well without destroying data trees the way flatten does.

1 Like