Asking for help on boolean (?) operations

Hi,

I try to create some parts based on user selection.
My current approach supports plane faces only. Current approach works like this:
for each selected face from a model (the green object in the attached picture) I cut the surrounding blue box into 2 pieces and I throw away the part, that contains the model.
After that I join all so created parts into a single part (cyan in the picture). The yellow waterlines are added to show, that the walls from the cyan part are not parallel.

To be able to support non-plane faces from selection as well, I'd like to change processing.
The idea for new processing is cut the selected faces by a horizontal plane. Result is a bunch of edges, that I could combine to a wire.

What I don't know: how can I extend an edge, so that it touches blue bounding box?
Or is there another/better way to support selection of arbitrary (vertical) shapes?

Attachments: