Isolate lines parts which overlap

Hi,

There are 2 components which consists of Lines.
I would like to ‘isolate’ the line parts from List B which overlap with List A.
(for visibility reasons I have plotted the lines below each other, but in reality they lay exactly on top of each other)

Question;
Create list C → containing line parts which overlap, ánd start/stop at every line end of list A.

image

2023-12-08 Isolate Line parts which overlap.gh (4.7 KB)

Note: the solution has to be generic. Meaning it should do the same thing if the lines in component A and B are changed completely.
For this example only lines in X direction are drawn (but its possible use lines which point in all directions),

Any suggestions?

Thanks

3. Attach minimal versions of all the relevant files

Something like this might work, if i understand the question correctly.

Pair up the lines, get the smallest. If you are looking to trim that is an option as well.


Rh7-Find-Collision-andSmallest.gh (11.4 KB)