Activate/deactivate "show3d" in Segmentation Editor via command line

Hello !
I am trying to dispaly a segmentation in the 3D view using the python interactor but i cant find the command to activate/deactivate the equivalent of “show 3D” in segmentation Editor.

for now i’ve tried :
segmentation = slicer.util.getNode(‘TC4_RH_ctg_mask.nii.gz’)
segmentationDisplayNode = segmentation.GetDisplayNode()

but it does not change the 3d display of the segment.
Thanks in advance :slight_smile:


The missing ingredient is CreateClosedSurfaceRepresentation()

See Script repository — 3D Slicer documentation

Amazing thanks ! it works perfectely fine :slight_smile:


This is not working in version 5.4.0 because of:

'vtkSegmentationCorePython.vtkSegmentation' object has no attribute 'GetDisplayNode'

How can I do it in this version?


GetDisplayNode is for vtkMRMLSegmentationNode (as returned by getNode) not vtkSegmentation. There are several layers, but they make sense to keep the methods localized by dependencies (vtkSegmentation doesn’t know about MRML so it can be used more generally in the future).