Generate STL file for each level

Hi,

Im trying to 3D print a revit model. To do so, Im creating a script to automatically divide the model in levels.
The next step I want to do is to generate a STL file for each level automatically and name the files accordingly.
Any ideas of how i could:
1- Generate the separate solids for each level.
2- Export them as STL named after the level they’re intended for.

Thanks in advance.