# 3D-view segmentation smoothing and stl export

**URL:** https://discourse.slicer.org/t/3d-view-segmentation-smoothing-and-stl-export/46488
**Category:** Support
**Tags:** segmentation, python, stl, smoothing
**Created:** [March 17, 2026, 10:31pm UTC](https://discourse.slicer.org/t/3d-view-segmentation-smoothing-and-stl-export/46488 "2026-03-17T22:31:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eva91](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eva91/32/79594_2.png) [@Eva91](https://discourse.slicer.org/u/Eva91)
#### Post date: [March 17, 2026, 10:31pm UTC](https://discourse.slicer.org/t/3d-view-segmentation-smoothing-and-stl-export/46488/1 "2026-03-17T22:31:53Z")

</div>

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!)

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [March 18, 2026, 10:50am UTC](https://discourse.slicer.org/t/3d-view-segmentation-smoothing-and-stl-export/46488/2 "2026-03-18T10:50:46Z")

</div>

Something like this should work:

```auto
segmentationNode = slicer.util.loadSegmentation(filePath) # Need to define filePath
segmentationNode.CreateClosedSurfaceRepresentation()
folderItemID = shNode.CreateFolderItem(shNode.GetSceneItemID(), segmentationNode.GetName())
slicer.modules.segmentations.logic().ExportAllSegmentsToModels(segmentationNode, folderItemID)
modelItemIDs = slicer.util.getSubjectHierarchyItemChildren(folderItemID)
for modelItemID in modelItemIDs:
  modelNode = shNode.GetItemDataNode(modelItemID)
  slicer.util.exportNode(m, stlFilePath) # Need to define stlFilePath

```

Note that you need to specify the file names.
