Replace "flip last" from TreeSloth with native components?

Hello, I find myself using this component a lot: “Flip Last” and I wanted to replicate it using native components but I wasnt able to do it…

This is the description of the component:
Flip Last Matrix : Just like the flip matrix, except this can take in a tree with a deeper path structure. It identifies the last path index with unique values in it and flips that index number with the object count.

tree_sloth_early_bird01

Not sure but:
Canvas%20at%2020%3B42%3B02
Source:
{A}(i)
{A;B}(i)
{A;B;C}(i)
{A;B;C;D}(i)
{A;B;C;D;E}(i)
Target:
{i}(A)
{A;i}(B)
{A;B;i}©
{A;B;C;i}(D)
{A;B;C;D;i}(E)

Hey Dani,

Thank you, this seems to work, will it work for any kind of tree? Or I should keep adding up to F, G, H, etc?

Yes, you must add more. But also remember to simplify the tree before passing it to the path mapper, so 5 levels should be enough.

1 Like

Here’s a fully native way to “flip last” that works for trees of arbitrary depth:

Flip Last.gh (15.6 KB)

4 Likes

Awesome! Thank you Andrew.

As a general comment on moving plug-in components into standard GH2, when the time comes to start work on the GH2 component set, I’ll definitely start a public discussion for it. This will focus partially on what ideas I myself have, differences between GH1 and GH2, but also probably some discussion on stylesheets and standard naming/optionality/defaults and of course what useful components exist already as part of plug-ins.

I would very much like to have the consent of the original developer before ‘stealing’ their ideas, but we’ll cross those bridges when we get there. The good news is that when the time comes to make these decisions, it should be a heck of a lot easier to find, install and uninstall plugins via our package manager.

1 Like

Hey all! Any new component (native or otherwise) doing this?
I made a cluster of @andheum algorithm anyway.Flip Last Z.gh (10.8 KB)

Are you looking for this kind of mapping ?

Or general solution like this, without map-typing…unless i misunderstood it all :grin:

image

Flip Last Z_RE.gh (77.4 KB)

1 Like