Partition list A into list of list, based on values of list B

Hi all,

I’ve searched the forums and google, but couldn’t find a suitable answer (maybe I just don’t know the right terms to search on for this problem). I understand quite a bit of Grasshopper and it’s data management structure, but this problem I just can’t wrap my head around.

So, the problem I need to resolve is the following;

I have two line segments being intersected by 4 curves in total (see screenshot with line segments being intersected by curves). Now I have to find the intersection points of the line segments with the 4 curves, but these intersection points have to be sorted according to the line segments (i.e. line segment 0 has 6 intersection points, line segment 1 has 2 intersection points) and these intersection points have to be placed into two seperate lists (i.e. list 0 contains the 6 intersection points on line segement 0, and list 1 contains the 2 intersection points on line segment 1).

However, this doesn’t have to just stay at 2 line segments being intersected with a total of 4 curves. It can be 16 line segments, of which some don’t have curves intersecting, some have maybe 1 intersecting curve, and another has 6 intersecting curves. Whatever combination you can think of, it has to be possible. (see screenshot_partition option 1 & screenshot_partition option 2, where the list of the left is list A, and the list on the right is list B)

Why I need to solve this, is because the line segments have to be shattered on the intersection points
(the circles are there just to help decide at which point it should be shattered but can vary in sizes) The normal shatter curve component doesn’t work as it projects some intersection points onto other curves, somehow that’s build in into that component. So if I manage to split the list into lists of lists I can keep the right intersection points to the right line segments.

What i think I need to use is the component RELATIVE ITEMS (the multiple list one), but I really don’t understand how to use that one, and there’s almost no (comprehensive) information to be found on the internet on that component. But again, I can be wrong on this idea of how to solve it, as I’ve tried other options as well but can’t seem to find the solution.

So, if anyone knows how to solve this problem, please help me or let me know. I want to learn this part, but can’t solve it at the moment.

Grasshopper definition is added, with the basic problem that needs to be solved.
Partition list A into list of lists with help of list (9.7 KB)

Thanks in advance for your help!

I understand you need EACH line to intersect ALL curves, so this means you have to Graft your lines and flatten your curves. Also, use Curve | Curve component.
This gives you a 2-level tree (first level = the line, second level = the curve), if you trim the tree one level down, you get the expected result.

If you need to shatter the lines, then you should trim the ParamsA and feed that into Shatter.

Partition list A into list of lists with help of list (17.3 KB)

Ah wow, I tried this option before but always got a weird output that I couldn’t do anything with. Now with the trim tree it works indeed. Magic, just this one more component.

Thanks a lot magicteddy!