Delete all tree branches - except the First one

Hi,

Fairly simpel question.

Question: Delete All Tree Path - except - the first path-nr.
e.g.:

{1;2;7;7;7} → {1}
{2;3;8} → {2}
{8;0} → {8}

I have come up with the dollowing solution, however I have a feeling that there must be a more easy solution… (Path mapper component?)

any suggestions?

2023-05-18 Keep only - First - Tree Branch.gh (11.8 KB)

Thanks,

Tree Branch_2023May18a
Tree Branch_2023May18a.gh (12.9 KB)

Hi,

Thanks for your quick reply.
However the desired result is:

image
any suggestions?

That’s very different from what you asked! Moving the goal posts… :frowning:

Tree Branch_2023May18b
Tree Branch_2023May18b.gh (13.7 KB)

I’m fairly disappointed to learn that {x;*} → {x} does not work, I thought it was the case…
You could do that :man_facepalming:

A better approach would be to avoid these trees with different levels.

2023-05-18 Keep only - First - Tree Branch.gh (18.8 KB)

1 Like

Totally agree with your {x;*} statement…

But this is a nice workaround.

Many thanks

I never ever use Path Mapper for two reasons:

  1. It’s syntax is complicated.

  2. It’s fragile - when the upstream data structure changes, it breaks.

1 Like

I also tend to avoid it for the same reasons.

The solution with Replace Paths in the original post is the most robust solution, though a bit longer.

1 Like