# STL conversion to OBJ

**URL:** <https://discourse.slicer.org/t/stl-conversion-to-obj/11972>\
**Category:** Support\
**Created:** [June 9, 2020, 11:45pm UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972 "2020-06-09T23:45:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Queen\_Rei](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/queen_rei/32/6348_2.png) [@Queen\_Rei](https://discourse.slicer.org/u/Queen_Rei)\
**Post date:** [June 9, 2020, 11:45pm UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972/1 "2020-06-09T23:45:58Z")

</div>

Hello! I used the following code snippet to import a STL as a segmentation and export that segmentation into a OBJ.

Issue: Right now the exported OBJ seems to be lower quality than if I did this manually. I feel as though there many be a flaw in my approach. I would love some insight on the code snippet below. Thank you \<3

```
        # Load STL, import as segmentation, and export as OBJ
        stlSegmentationNode = slicer.util.loadSegmentation(inputFolder)
        segmentIDs = vtk.vtkStringArray()
        segmentIDs.InsertNextValue(fileName)
        slicer.vtkSlicerSegmentationsModuleLogic.ExportSegmentsClosedSurfaceRepresentationToFiles(outputFolder, stlSegmentationNode, segmentIDs, "OBJ", True, 1.0, False)
```

---

<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:** [June 10, 2020, 12:29am UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972/2 "2020-06-10T00:29:00Z")

</div>

There should be no difference at all. Could you post a screenshot that shows what difference you see between results of different methods?

---

<div class="post-metadata">

**Author:** ![Queen\_Rei](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/queen_rei/32/6348_2.png) [@Queen\_Rei](https://discourse.slicer.org/u/Queen_Rei)\
**Post date:** [June 10, 2020, 4:10pm UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972/3 "2020-06-10T16:10:03Z")

</div>

The original STL is: 347 MB  
In essence I would like to replicate this manual process in a module:

1. Import STL as segmentation  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/e/8e5ae6352058a66375571a4cf830ce414c7f2727.png)
2. Export the segmentation as a OBJ  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/2/e26f3e44b73ba2d0233c3a95bb8f61d674fc9f0c.png)  
**Output OBJ’s look like this**  
Manual STL-\>Segmentation-\>OBJ: 316 MB  
Script STL-\>Segmentation-\>OBJ: 288 MB

I am wondering why the sizes may be different between the manual process and the script.

---

<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:** [June 10, 2020, 4:54pm UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972/4 "2020-06-10T16:54:18Z")

</div>

Probably the difference is that you set size scale of 0.005 on the GUI. Since OBJ is a text-based format, if you change the scale then coordinate values may be longer/shorter (“5” is shorter than “0.005”).

Why did you set scale to 0.005 on the GUI? Normally you should set it to 1.0 (to export in mm), but you can change it if you want to export in meters or inches - but 0.005 does not seem to correspond to any commonly used distance unit.

---

<div class="post-metadata">

**Author:** ![Queen\_Rei](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/queen_rei/32/6348_2.png) [@Queen\_Rei](https://discourse.slicer.org/u/Queen_Rei)\
**Post date:** [June 10, 2020, 5:15pm UTC](https://discourse.slicer.org/t/stl-conversion-to-obj/11972/5 "2020-06-10T17:15:34Z")

</div>

Ohh! My apologies, I completely overlooked how that may be effecting it. I set it to 0.005 thinking it would scale it down (it is arbitrary, since I was just testing it out earlier - didn’t think it would effect the file size). Based on what you are saying it makes most sense to just keep it at 1mm, so I will do so.

Always appreciated! Hope you and your family/friends have been safe \<3
