Loading a 3D model from Blender or other 3D modeling applications (STL, 3DS, FBX file format) into the scene programmatically using Python

Hi,

I have a polygonal 3d model file and I want to import it to the scene. I can do it through user interface but I wanted to know how can I achieve this through code.

Thanks,
Hadi

Hi:

slicer.util.loadModel("/path/to/file.ext") will work for this purpose.

See: https://www.slicer.org/wiki/Documentation/Nightly/Developers/IO#How_to_load_files_programmatically

Supported data formats can be found here:
https://www.slicer.org/wiki/Documentation/4.10/SlicerApplication/SupportedDataFormat

1 Like