@Cyril I am not currently aware of a safe way, even with closed source software. Any software which does any translation at the moment cannot be trusted to safely split anything up - this goes for all BIM authoring tools that have an import / export function. There is no single tool that does translation that supports translating the full breadth of the IFC schema right now.
The only tools capable of doing it safely would be underlying IFC parsers, like IfcOpenShell, or others like XBim. If a closed source package has this offering, they must do it with their parser without doing any translation steps. I would be interested to know if one exists. Perhaps something like Solibri Optimiser. Even then, I would treat it with caution. Will it make assumptions, or can I count on it to preserve less-obvious data that may go missing, like IfcProcess
, IfcResource
, IfcTelecomAddress
...?
The safest way to write this with IfcOpenShell is as you've described - to look at everything, and delete one by one. However, element deletion is expensive, because all relationships must be considered to all other elements. It may also leave the file in an invalid state, perhaps breaking some IFC WHERE rules. Also, deleting the object doesn't mean the geometry is also deleted (which may be shared with non-deleted elements), which means additional checks need to be written. In short, the quick way of writing it may indeed cut down the number of elements, such that your 800MB file can then be opened by an importer, but it may not necessarily cut down the filesize, which may mean that your importer won't be happy still. Vice versa applies: the slow way of writing it will do it carefully and properly, but may take annoyingly long to execute.
If instead we redefine "safely" based on some common heuristics like we assume geometry is the biggest bloat, and that our BIM authoring tool focuses on BIM products instead of non-rooted elements then it becomes a bit easier and we can get a relatively quickly processed file with the important stuff retained. Here's an attempt, which takes an input file and outputs one IFC file per IfcBuildingStorey. It is an IfcPatch recipe called SplitByBuildingStorey. Here's an example output when I ran it on a 250MB IFC file and took out the lowest storey. In my test of that file, which had 34 storeys, the lower levels (which were bigger) were reduced to approx 20MB each. The higher levels were smaller.
You can run it with: ifcpatch -i input.ifc -r SplitByBuildingStorey

Note that the sum of the IFC files will very likely be greater than the original IFC file due to geometry reuse.
Let me know if it works for you and if you come across any issues :) Ping @aothms who might have a cleverer way of doing it, especially to remove the need for the disk read/write per storey - that could easily add a good 20 seconds per storey for your 800mb file just for the read/write portion of it, regardless of processing the elements. In short, maybe make some coffee while running the script, and keep a close watch in the cwd for results (first you'll see a pure copy of the file with the full 800MB, then it'll overwrite it with a much smaller version)