Problem with sweep

I am trying to make up a parametric window unit and enclose the grasshopper file to show where I have got to.

The intention is to make up a set of profiles, to extrude / sweep these to make up the different elements within the window and to then Boolean these together. Enclosed is my current grasshopper file to illustrate where I have got to.

I am having problems with the main window frame which I am trying to construct by sweeping a profile along a polyline and when I try to cap the frame element which is constructed the difficulty is that I get varying results with the resultant geometry being either a closed, open or invalid breep depending on the height of the frame.

To illustrate this the resultant frame in the attached file (at a width of 1200 mm) is a closed breep at a height of 975 mm, an invalid breep at a height of 1000 mm and an open breep at a height of 1135 mm.

Can anyone explain why this should be and how I can amend the routine to achieve a reliable closed breep at all frame heights.

test File 05.05.18.gh (47.1 KB)

Robbie

test File 05.05.18.gh (47.1 KB)

Please find the attached .gh file.