brhoom
(ibr_ex@yahoo.com)
1
Operating system: Ubuntu 18.04
Slicer version: 4.10
This is not a question but a simple example for beginners. The sphere can be replaced by other polydata object.
import vtk
source = vtk.vtkSphereSource()
source.SetRadius(50.0)
source.SetCenter(0,0,0)
source.Update()
pd = source.GetOutput() # a polydat aobject
slicer.modules.models.logic().AddModel(pd)
1 Like
lassoan
(Andras Lasso)
2
Thanks for taking the time to share this. We maintain a list of code snippets in the script repository. It would be great if you could add it there.
I also have a suggestion for possible simplification of the code, using the source’s output port:
import vtk
source = vtk.vtkSphereSource()
source.SetRadius(50.0)
source.SetCenter(0,0,0)
modelNode = slicer.modules.models.logic().AddModel(source.GetOutputPort())