Extend curves to a given input guideline

Hi there,
I have a set of horizontal lines which differ in angle. Now I want to give an “offset-guideline” to which those lines should be extended. The problem here is that there’s not one guideline for every side, but some share guidelines. Any suggestions how to solve this problem?
I tried with extruding the guidelines to a surface, then searching for intersection points to then find out about the extension length… but I struggled with data structure. Also, I’m not sure if that’s the right way to go. Maybe it’s better to work with some kind of “Trim” component?

230415_Extrusion_and_Cut.gh (28.0 KB)

Data structure mismatch, no way this is going to work.

For each line (=> Graft), test all intersections (=> Flatten) - there should always be exactly two.

230415_Extrusion_and_Cut.gh (30.0 KB)

Got it! thank you so much for the fast response! that’s exactly what I was looking for.
I tried with Surface|Curve which didn’t work, but Brep|Curve seems to do the job.

so again, the implementation of the code to the specific layout I have, brought some problems I can’t figure out…

In very few areas, the lines choose to intersect three times instead of only two. I would understand if this happened for every line, but just for a couple…?
230415_Extrusion_and_Cut.gh (92.3 KB)

…and that one doesn’t work either…

ok, “reverse” did the job, but still no idea why I need to do this…

The problem is that your extension value is so high some lines extend to three surfaces instead of two, when they are close.
You could try to reduce that extension value…
Or this is a definitive workaround : test the intersections for two half curves and only keep the first one (it should always be the first along the line).

230415_Extrusion_and_Cut(1).gh (99.6 KB)

oh yes I see. The extent value was higher than necessary. thanks!!