How to broke line by square and get zhe segments outside the square?

After the line is interrupted by a square block, I want to obtain the segments outside the square.
I am poor at C#, Crashing…

test.gh (14.9 KB)
test1.3dm (89.1 KB)

Get the general case. In fact there’s 2 ways to skin the cat on that (Split and CurveCurve ccx events).

Used here the most naive way (recursion on Split): as a challenge try to do it with the orthodox (ccx) way.

Intersect_test_56A.gh (119.5 KB)

And this is the proper and 100 times faster way (ccx events) to skin the cat. But some Methods used are internal.

Just a hint:

thank you very much!