# Save segmentation directly to STL or OBJ files

**URL:** <https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428>\
**Category:** Support\
**Tags:** feature\
**Created:** [March 26, 2018, 4:14pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428 "2018-03-26T16:14:44Z")\
**Posts on this page:** 9\
**Page:** 1

<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:14pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/1 "2018-03-26T16:14:44Z")

</div>

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:

[![](https://img.youtube.com/vi/WfuYPVYA5cA/maxresdefault.jpg "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 system can be LPS (for compatibility external software) or RAS (for compatibility with current default model save in Slicer)

The tool is available in Segment editor module (“Segmentations” button / drop-down arrow / “Export to files”) and in Segmentations module (“Export to files” section).

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/b/3b9e77aace22e8fdd5d5ce55e5c3aca9e6755564.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/b/9b84e7fe940c2694661735669be71fb9848de5e8.png)

---

<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, 6:01pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/2 "2018-03-26T18:01:16Z")

</div>

Out of interest in the video what is viewer you are using for STL visualization?

Ah found it, Mixed Reality viewer for Windows 10.

---

<div class="post-metadata">

**Author:** ![labixin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/labixin/32/1965_2.png) [@labixin](https://discourse.slicer.org/u/labixin)\
**Post date:** [January 16, 2019, 7:18am UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/3 "2019-01-16T07:18:21Z")

</div>

Dear Andras,

I have succeeded in exporting all segments together in one file. But I still have two questions. The first is about exporting STL file. What do you mean by “all segments merged into a single mesh” when ticked the box “Merge into single file”? Does the single mesh still compose of different segments or just merge into one mesh? I have export STL file to Solidworks and found three parts the same in Slicer (as shown in the following figure). The second is that when exporting OBJ file, I found another solid apart from the three segments (a very small spot??). I really don’t know where it may be from. Could you give some advice? Thank you very much!

Best regards,  
Crayon

 ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/2/520930821fd6ae183ca4e5666fb9fa76ca6d8bd9.jpeg)

---

<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:** [January 16, 2019, 12:51pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/4 "2019-01-16T12:51:28Z")

</div>

> [@labixin](#):
>
> What do you mean by “all segments merged into a single mesh” when ticked the box “Merge into single file”?

If merge is enabled then all mesh points and triangles of the three segments are included in a single file. If you want to manage the segments separately then turn off this option.

> [@labixin](#):
>
> I really don’t know where it may be from. Could you give some advice?

If you did not intend to create that segment and don’t need it then you can delete it.

---

<div class="post-metadata">

**Author:** ![labixin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/labixin/32/1965_2.png) [@labixin](https://discourse.slicer.org/u/labixin)\
**Post date:** [January 16, 2019, 1:12pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/5 "2019-01-16T13:12:31Z")

</div>

I got it. Thank you!

---

<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 14, 2021, 2:10pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/6 "2021-03-14T14:10:10Z")

</div>

2 posts were split to a new topic: [Keep DICOM coordinate system when exporting segmentation](https://discourse.slicer.org/t/keep-dicom-coordinate-system-when-exporting-segmentation/16533)

---

<div class="post-metadata">

**Author:** ![rjk](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rjk](https://discourse.slicer.org/u/rjk)\
**Post date:** [April 15, 2021, 8:35am UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/7 "2021-04-15T08:35:21Z")

</div>

Newbie here requesting a hand:

I exported using “export segments to files” a segmentation of several structures, with color and opacity set for each, into a merged OBJ but upon loading it back into Slicer none of the color and opacity settings were preserved. The entire model was default yellow. Additionally, when I tried to scale the size down for the sake of storage space, but whether the slider is 1 or 0.3 the output file size remains the same.

Any advice for these 2 newbie issues? Thanks!

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 15, 2021, 10:55am UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/8 "2021-04-15T10:55:40Z")

</div>

This is a great new function. Thank you !

---

<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 15, 2021, 12:33pm UTC](https://discourse.slicer.org/t/save-segmentation-directly-to-stl-or-obj-files/2428/9 "2021-04-15T12:33:09Z")

</div>

> [@rjk](#):
>
> I exported using “export segments to files” a segmentation of several structures, with color and opacity set for each, into a merged OBJ but upon loading it back into Slicer none of the color and opacity settings were preserved. The entire model was default yellow. Additionally, when I tried to scale the size down for the sake of storage space, but whether the slider is 1 or 0.3 the output file size remains the same.

“Export to files” feature is for exporting for 3D printing or visualization/processing in external software. If you want to preserve colors and all other display properties then save the segmentation using File / Save.

When an OBJ file is loaded into Slicer then the texture/color information is ignored but the `MaterialIds` cell array is made available in the mesh. This array contains a different value for each segment, and you can choose to use this value for coloring in Models module’s Scalars section. If you choose a color table that matches the original segment colors then you can make the model appear similarly as it was exported.

> [@rjk](#):
>
> Additionally, when I tried to scale the size down for the sake of storage space, but whether the slider is 1 or 0.3 the output file size remains the same

This feature is for scaling of coordinates (for example, if you want to have your model coordinates to be defined in meters instead of millimeters). You can find explanation of all parameters in tooltips.
