Remove a specific item from two separate branches

Hi, brief data structure question,
I am sure it’s been answered elsewhere but I have brain failure right now.
I want to remove the first item (point) of one branch and the last item (point) of another branch.
:face_with_peeking_eye:
Data example:


I want to remove the bottom point and the top point.

sortedpoints.gh (11.0 KB)
Thanks for your suggestion(s) - I appreciate it

Hi, there is propably better solution, but this works:

1 Like

Here you have script, I’ve also added an example with removing first point in first branch and last point in the last branch
sortedpoints_somehowWorks.gh (15.0 KB)

1 Like

There are many ways to go about this. Here’s a couple of options, both produce the same output.

231006_sortedpoints_re01.gh (18.8 KB)

-Kevin

2 Likes

Sincere thanks to both of you @msajdek and @kev.r - I was definitely experiencing a blockage and both methods have helped me. What I realized later was that I should have been a bit more specific in my description stating I meant to stay away from flattening data anywhere as this is part of a significantly larger script - however honestly I don’t know what I was thinking (probably too late at night and too tired) fearing I’d lose my data structure and was not going to be able to shift the paths again (rookie mistake) - hence grafting it prior to the operation is definitely what I should have considered in order to remove paths 0 and -1! Then I betrayed myself ‘flattening’ via shift paths first to then end up grafting in the Dispatch component :sweat_smile:

Kevin, the method on the top of your script adheres more to my original ‘wish’.
Msajdek, your method helped me get to my method.

Best,
René

1 Like

Hi again @kev.r - thanks to the help provided here I moved forward with the project, and I am back with a brief question for you: how would you properly ‘return’ to the initial list structure after having re-ordered the points?

Put simply, after performing the culling following your example, I sorted the kept points based on polar coordinates:

Now I would like for the first and last elements to be put back into the structure but with the new order of the modified list in between.

This means that the new list (#2) goes back to 6, 6, 6 instead of 5, 6, 5:

I had an error attempting replace items where I didn’t manage to retain the new arrangement of the culled points while keeping the bottom point as first item for the first branch and the top point as last item for the last (third) branch.

I imagine it’s something simple I’m ignoring.

I thank you in advance!
sortedpoints2.gh (14.0 KB)

Here’s one way.

  1. Replaced Tree Branch component with Split Tree component.

  2. After sorting points, use Unflatten Tree component to restore DataTree structure.

  3. Merge ‘culled points’ back with ‘sorted points’.

sortedpoints2_re.gh (20.5 KB)

-Kevin

1 Like