Exporting a model to STL with markups

You could use a Python snippet like this

fiducialNode = getNode('F')
import numpy as np
sphereSource = vtk.vtkSphereSource()
sphereSource.SetRadius(1)
for i in range(fiducialNode.GetNumberOfControlPoints()):
  p = np.zeros(3)
  fiducialNode.GetNthControlPointPosition(i, p)
  fiducialModel = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode', f'Model_{fiducialNode.GetName()}_{i}')
  sphereSource.SetCenter(p)
  polyData = vtk.vtkPolyData()
  sphereSource.Update()
  polyData.DeepCopy(sphereSource.GetOutput())
  fiducialModel.SetAndObservePolyData(polyData)

Please note you’ll need to replace the name of your fiducial node (in my example it is F) and set the sphere radius as desired.

Once you have the model nodes you can append them together in Dynamic Modeler module’s Append feature, then export to STL.

2 Likes