Script repository "Add a texture mapped plane to the scene as a model" has error

From an empty scene, pasting the code from the “Add a texture mapped plane to the scene as a model” section from the script repository (https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Add_a_texture_mapped_plane_to_the_scene_as_a_model) into the python interactor and running it doesn’t show anything in the 3D view. I’m running 4.11.0-2020-01-08.

I see that there is an error in the log
AttributeError: ‘MRMLCorePython.vtkMRMLModelDisplayNode’ object has no attribute ‘SetAndObserveTextureImageData’

I guess this might be related to the VTK version 6 update? If it’s just not functional at this point, might want to make a note of that on the Script Repository page. Though, thinking about it, someone must have figured out how to do this, because the slice views visible in the 3D view accomplishes the same functionality (getting an image displayed on a plane in the 3D view) and more. A functional demo script in the repository would helpful. Thanks!

It was an ancient code snippet. I’ve updated it now to match current Slicer API.

You may also consider using TextureModel module in SlicerIGT, which can take care of loading and properly aligning the texture that comes from surface scanners and can also set texture information in point scalars so that it can be used by filters and saved in VTK mesh files.

1 Like