Convert a 3D component to a 2D face

How do I convert a 3D component to a 2D face on the X-Y plane, using Ruby?

From this -
I want this component to be shrunk and left with just a face on the x-y plane.

When I use pushpull, giving the exact same height as of the component, it completely disappears.

Collect all of the edges in the component [perhaps make a unique copy so as not to ruin the original ?]
the iterate the edges and erase those which have different edge.start.position.z and edge.end.position.z - i.e the are not ‘flat’.
You have now erased the ‘vertical’ edges and need to process the rest…

In your example there are two faces left…
Assuming the bottom face is the one you want to keep, and it’s facing ‘down’ just find the face.normal.z>0 then erase it.
The remaining one face is left - you might want to use face.reverse! on it to flip it to face up - assuming it’s already facing ‘down’ ?

Thank you, sir.
This worked!