Can Python interpretor be used to call Slicer IGT "create models" ?


I am a fairly new user of 3D Slicer. I was wondering if it is possible to call the “CreateModels” functions of the Slicer IGT module from a python script.
I need to create cylinder models in a more automated way, thus I wanted to combine python and Slicer IGT for this.

A more general questions: Can all the modules be called from python ?

Thank you

The short answer is yes, all Slicer modules can be accessed from python.

Here’s a very long answer: Developer Guide — 3D Slicer documentation

Self tests can be a good place to look to try to find examples of code in use. Here’s one I found which seems to use the IGT create models functionality in a basic way:

Here is the C++ code for the Create Models module: SlicerIGT/vtkSlicerCreateModelsLogic.cxx at 39dfcfa3c83e07981054b6e2164c5f26552b93bb · SlicerIGT/SlicerIGT · GitHub

Those C++ functions are wrapped and accessible via python.

1 Like