# Multisegment merging into one model for STL export

**URL:** <https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424>\
**Category:** Support\
**Created:** [March 26, 2018, 1:30pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424 "2018-03-26T13:30:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Scales](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@J\_Scales](https://discourse.slicer.org/u/J_Scales)\
**Post date:** [March 26, 2018, 1:30pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/1 "2018-03-26T13:30:30Z")

</div>

New to using 3D slicer and have followed the cardiac segmentation video and had a question regarding export of the segments into STL. It seems that when one goes to export each segment as a model they are exported as there own segment (meaning 8 stl files for 8 segments). Is there anyway to combine the segments as one STL file? I have tried the logical operator tab Add function (not sure if I used it correctly) but am not sure if this would be the solution. I am using Slicer 4.8.

Anyway thanks for any tips and answers. This is a great program.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 26, 2018, 4:16pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/2 "2018-03-26T16:16:41Z")

</div>

Latest nightly version of Slicer has a dedicated file export feature. You have the option of saving as merged STL (all segments merged into a single mesh) or OBJ (single file, segments are different objects). See details here:

> [@Save segmentation directly to STL or OBJ files](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj/2428):
>
> We often received questions about how to export segmentation to STL file for 3D printing. We’ve added a simplified, dedicated tool to make this step easier. 1-minute demo video: [[Export Slicer image segmentation to STL or OBJ file] ](https://www.youtube.com/watch?v=WfuYPVYA5cA) Main features: Export STL file: each segment as a separate file or all segments merged into a single mesh Export OBJ file: all segments are saved in one file, segment colors and opacities are preserved Export all or visible segments only Coordinate sy…

---

<div class="post-metadata">

**Author:** ![J\_Scales](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@J\_Scales](https://discourse.slicer.org/u/J_Scales)\
**Post date:** [March 26, 2018, 4:25pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/3 "2018-03-26T16:25:55Z")

</div>

> [@lassoan](#):
>
> Latest nightly version of Slicer has a dedicated file export feature. You have the option of saving as merged STL (all segments merged into a single mesh) or OBJ (single file, segments are different objects). See details here:

Really appreciate this response and the video. Good to know the latest nightly build has this built in.

---

<div class="post-metadata">

**Author:** ![Anis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anis/32/3547_2.png) [@Anis](https://discourse.slicer.org/u/Anis)\
**Post date:** [April 26, 2019, 10:03am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/4 "2019-04-26T10:03:57Z")

</div>

Operating system:Windows 7  
Slicer version:Slicer4.9.0  
Expected behavior: stl file for the merged model  
Actual behavior:error in merging the two segment model  
Hi,

I am working with Slicer4.9.0. I want to generate stl for a sample having two regions.

I could generate stl for both regions individually but when I try to merge model Slicer shows error and gets close.If I try to add the two segments using logical operation I get an stl but that shows error in Gmsh which I use for further mesh refinement.I have tried this process with Slicer4.8.1 also.  
I don’t have dropbox to tranfer files.The mrml for segmentation and the snapshot showing errors could be sent through mail.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 26, 2019, 12:29pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/5 "2019-04-26T12:29:55Z")

</div>

> [@Anis](#):
>
> I am working with Slicer4.9.0.

Use latest stable version (Slicer-4.10.1) or later.

> [@Anis](#):
>
> Gmsh which I use for further mesh refinement

You can use SegmentMesher extension to create high-quality multi-material meshes directly in Slicer.

> [@Anis](#):
>
> I don’t have dropbox to tranfer files.

You can use any other online storage provider.

---

<div class="post-metadata">

**Author:** ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)\
**Post date:** [August 13, 2019, 2:22am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/6 "2019-08-13T02:22:07Z")

</div>

Hi Andras,  
I want to use gmsh within slicer. The problem I am having is I am unable to view the vtk files generated by using gmsh and meshio.

Also another problem is that I create a surface model node. how can I use this surface model node as input to gmsh. any suggestions?

Also if I use the segment mesher I found it generates a mesh from label maps but the mesh is not refined. thats Why I now jumped to gmsh. Any suggestions?

So I need to now create mesh using surface model nodes generated by slicer and using these surface model nodes to generate the mesh through gmsh. Any suggestions How can I read the surface model node in gmsh

Thanks

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 13, 2019, 2:45am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/7 "2019-08-13T02:45:15Z")

</div>

> [@Saima](#):
>
> if I use the segment mesher I found it generates a mesh from label maps but the mesh is not refined. thats Why I now jumped to gmsh. Any suggestions?

What do you mean by “not refined”? By default mesh generation is set up to be very quick and generate a course mesh. You can adjust the parameters to preserve all relevant details of the surface mesh.

---

<div class="post-metadata">

**Author:** ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)\
**Post date:** [August 13, 2019, 5:10am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/8 "2019-08-13T05:10:07Z")

</div>

Sorry I mean fine mesh. How can I get a fine mesh using segment mesher with only one label map.

Thank you

Regards,  
Saima Safdar

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 14, 2019, 5:16am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/9 "2019-08-14T05:16:59Z")

</div>

See this tutorial: [https://github.com/lassoan/SlicerSegmentMesher#tutorial](https://github.com/lassoan/SlicerSegmentMesher#tutorial). Near the end there is a step to create a finer mesh.

---

<div class="post-metadata">

**Author:** ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)\
**Post date:** [August 14, 2019, 6:44am UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/10 "2019-08-14T06:44:01Z")

</div>

Hi Andras,  
I checked with multiple values for scale but it always give me a mesh with some external elements which are not in the label map in segmentation.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/1/318e5d4b06c72476e93c363eb7dd9c62687f9619.jpeg)

For example see in the fig above. the label map is ok but mesh is not ok. why am i getting the mesh like this and not exactly what I needed from the label map of brain.

thank you

any suggestions please

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 14, 2019, 3:10pm UTC](https://discourse.slicer.org/t/multisegment-merging-into-one-model-for-stl-export/2424/11 "2019-08-14T15:10:26Z")

</div>

You can add a box-shaped segment around the brain (e.g., using Scissors effect, with appropriate masking settings). You can then extract sub-meshes by thresholding based on material ID cell scalar.
