Flatten portion of a curve

Hi everyone. I’m having trouble with something that seems rather simple. I’m trying to create a series of grandstands that become a roof, which means the grandstands become flat. Is there any way I can flatten these curves smoothly in an specific section? (Red one). Here is the script and the rhino file.

Thanks :slight_smile:

SPORT FIELDS.3dm (1.7 MB) SPORT FIELDS.gh (13.3 KB)

Forgot to post the screenshot.