How to export model node to VRML 2 and STL (ascii and binary)

Hello,

I need to be able to export a model node as VRML 2, ascii STL, and binary STL files for a module I am developing. I know essentially nothing about vtk so any help or resources you could provide would be lovely.

Thank you!

The easiest to export to binary STL and OBJ is to use this ExportSegmentsClosedSurfaceRepresentationToFiles method.

VRML is really really old, I would not recommend to use it, but fortunately VTK still supports it. VTK also has ASCII option for writing STL. You can do the export in two steps:

  1. Export segmentation to model - se example here
  2. Get vtkPolyData from the created model nodes and use vtkSTLWriter and vtkVRMLExporter. See examples for getting vtkPolyData from a model node and write to file in script repository; a complete example of using an exporter in this module.
1 Like

Perfect, I got it working. Thank you so much!

1 Like