3D-view segmentation smoothing and stl export

Hi,

I have a working manual workflow in Slicer, where I load a segmentation, then show it in 3D, and increase the surface smoothness via that tiny arrow on the “Show 3D” button. After that, i export the segmentation to stl.
Now I wish to do this on many cases; can you help me and guide me through how I could do all this via Python, without having to open Slicer?
So basically, how do I, via scripting, load segmentation and smooth it (in the sense of smoothing the 3Dview) with a specific smoothing factor, and then export the new (smoothed) view into stl?

Thank you! (Also, I’m completely new to Slicer scripting, so even the most basic advice is welcome!)