Rearrange data tree

Hi Everyone,

I have a simple thing to do, but it is absolutely stumping me.

I have a data tree of 12 branches of 3 things; a, b, c, and I would like to rearrange it into 3 branches of 12 things; all the as, all the bs, and all the cs.

I think it is a path mapper thing, but I am not familiar with this and cannot work out what formula to put in that gives me anything but “No data was collected”

Maybe it’s something else - I have tried a bunch of the different branch/path modifiers and nothing seems to work. I tried searching for a solution, but don’t even know how to phrase it and get a result that works. If anyone could help that would be greatly appreciated.

:rofl: :rofl: :rofl:

3. Attach minimal versions of all the relevant files

Flip Matrix :question:

Hi Joseph,

Sorry for not including the file, it was a bit of a mess and difficult to “minimise” and it’s only the 1 thing that I am having the problem with.

As you can see when it is arrayed along the curve it puts it into 3 branches of 12, which then works with the vertical movement afterwards.

I tried using “orient” as I needed to control the array distance, but this puts it into 12 branches of 3 which doesn’t work.

I am aware that this might be the “wrong” way to do this whole thing, but my main issue is rearranging the branch to match the “array” version, because it seems like it should be an easy thing to do, but I just don’t understand how it works from the explanations and examples I have found.

rearrange branch.gh (27.3 KB)

Flip matrix seems to do that :expressionless:

Thank you for that.

You may find this link helpful for a cheatsheet of common Tree operations. It provides each tree operation in Path Mapper syntax, which is the more generic “rearrange a tree and its branches” node. Just fair warning this might make everything seem more confusing than it is. If Flip Matrix is all you need, don’t feel obligated to take this dive into the messy details.

Thank you for that, I think I did look at that - my brain seems to be incapable of unwrapping what the syntax actually means - what an {A} is. It’s a strange foreign land, thank you for helping me find my way.

No worries, it took me a while too. I was coming from other programming, but never got good enough to use any particularly complex data structures.

Maybe i’m repeating things you already understand, but here’s how I think of and teach it…

A Tree has Branches, each of which are identified by their Path.
Data is on that branch at some index.

To understand what a Path is, you might think of a suburb. The branching streets of a neighborhood form a tree structure and the houses all have addresses –paths. Some addresses are empty lots, and other ones have houses on them. Once you define the streets, its easy to add and remove houses without having to renumber the existing ones. The path is “where the data lives”, which in grasshopper can be changed around or renumbered with very little extra computation or slowness. That’s what tools like graft, simplify, trim tree, and shift path do.

So, the syntax {1,3,5,6} reads left to right as something like

The first highway exit, third avenue, fifth cul-de-sac, sixth house"

The format {A;B;C;D} in path mapper is a succinct way to describe the path structure

highway A; avenue B; cul-desac C; house D

I’ll use the same notation when commenting my scripts,

row A; col B; brep C; face D

or I’ll write it simply

row; col; brep; face

That way, I can remember which part of the path is numbering what. In the pathmapper, you also use a standard i index notation to refer to an item. To extend the analogy, it might be “…house D, floor i”.

{A;B;C;D}(i)
{highway; avenue; cul-desac; house}(floor)
{row; col; brep; face}(control point)

The path mapper lets you do arbitrary changes of the structure by using that abcd(i) format.

Maybe its not relevant to learning, but I find this page helps, where David Rutten explains why he chose to use trees over the more common data structure of lists of lists:

2 Likes