How to combine segments into a single polycurve for a sweep?

Hello, I am trying to model streets on top of a toposurface (with a sweep), to help the office with templates for urban design modelling, including of course parametric profiles for streets, footpaths and toposurfaces. I have successfully incorporated so far a script (thanks HyunWoo!) that turns contour model lines into a toposurface, and another that projects a flat model line onto the toposurface, which will serve as the base for the street sweep.

My problem is that the projected lines (green in the image) are a group of individual segments rather than a single polyline, so the sweep path for the street does not translate well and results in a group of different sweeps with the same origin but in different direct ions. I have tried using PolyCurve.ByJoinedCurves, List.Join, but with no avail…

So, the question is: How can I combine all the segments into a single polyline to correct the sweep?

Just as a reference, I have tried in the past to model streets using an adaptive component profile family, but was not able to keep the orthogonality (horizontal) of the street when some of the points had a positive/negative Z coordinate. For that reason I discarded that option and am trying to model streets this way instead.

Any help will be greatly appreciated.street testDynamo street sweep Street Sweep