Help with script to connect aligned vertexes of a spline ?

Hello Guys, I need a little help with script creation and I thought maybe anyone here could help. I want to create a script that's capable of creating multiple splines (or connecting multiple verts of a spline) in a given axis of aligned vertexes. For example, in the image bellow, I need it to close the selected spline to form 3 rectangles. I thought maybe I could make this happen by telling the script to connect the vertexes that are aligned in Y axis, in this example. And this is what I got so far, I cant tell Maxscript to enter in the sub_object and then click the connect button. But I have no clue how to do the rest.

Here is a very simple example of what I'm trying to do :

Connect the aligned vertices in Y axis, in this example, to create multiple rectangles with it. Since I work with architecture modelling I do this all the time to create the walls bellow a window or a door. Maybe another way to do it could be creating multiple shapes in Y axis to form the rectangles and then weld the vertices later on (but it seems a bit more complicated, idk). Could anyone help ? It would be very handy to me and maybe to others too :)

script_spline_creation.jpg113.63 KB
script_spline_creation_2.jpg25.39 KB