There is an (unnecessary) limitation in the vtkOBJExporter that causes the issue. I’ve submitted a pull request with the fix (coincidentally, I’ve just worked on OBJ exporter problems and included this fix as well): https://gitlab.kitware.com/vtk/vtk/merge_requests/4084
Until the fix is integrated, you can use a workaround of moving the renderer to another render window. This allows the export to complete successfully and then the application crashes (if the goal is to just export to OBJ then the crash should not be an issue).
lm = slicer.app.layoutManager()
tdv = lm.threeDWidget(0).threeDView()
rw = tdv.renderWindow()
# Move renderer temporarily into another renderWindow
# It will make the application crash, but it allows the scene export to complete successfully.
rw2 = vtk.vtkRenderWindow()
rw2.AddRenderer(rw.GetRenderers().GetFirstRenderer())
o = vtk.vtkOBJExporter()
o.SetFilePrefix('c:/tmp/test')
o.SetRenderWindow(rw2)
o.Write()
Thank you so much, it works like a charm …Finally got the obj output.
please update once this issue gets resolved or any other non crashing solution you get,