Start off by clearing everything, by using:
model = Sketchup.active_model model.entities.clear!
then purge the model using:
model.definitions.purge_unused model.active_layer=model.layers[0]; model.layers.purge_unused model.materials.current=nil; model.materials.purge_unused model.styles.purge_unused ds = model.attribute_dictionaries; ds.to_a.each{|d| ds.delete(d) } if ds
Now you have an empty SKP.

Try doing the import AND export within a model.start_operation(...) block, BUT do not ' commit' it, rather you need to ' abort' it after each one.
That way the import happens, the export happens but the changes to the model are undone by each ' abort'. The exported file is NOT undone by the ' abort' !