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