Peter,
Keep in mind, whatever quirks which may occur within the code I posted would be fixed when it's converted to a sub-function within SF. But that's a moot point...
Take a look at the file named 3D House.dwg in ACAD Samples folder. It contains many 3DSolid objects and some 2D objecs. I used that file while testing SF.
I change the file to top view and Visual Style 2D Wireframe. If I run the code I posted and select the 3DSolid table between the two couches, the result is not correct. The WMFIN block is wrong in terms of location and scale. I'm not inclined to investigate why given the following. If I run your version of SF with the Flat3D function and select all, the file is correctly flattened.
I'm not surprised to find the function I posted failed. I suspected it might given examples other than your example file. Junk that idea.
Another observation with that file. If I use the flatshot command and place a new block in the drawing, all 2D objects are not included in the new block. Example: the door swings are 2D arcs and lost in resulting flaltshot block.
There's a lot to think about here in terms of what SF should do and what options it should offer.
Also note, the current verion of SF flattens the 3DSolid objects in the 3D House file using (command "explode"). Of course it does not work well with your Pump example file.
My thoughts at this point are as follows. Use your Flat3D function as is. Probably removed the (command "explode") idea. And if any 3DSolid or similar objects are detected in SF selection set, including those in blocks, offer an option to exit SF and suggest the flatshot command given 2007 or later.