GetDisplayNode returns 'NoneType' after I create manually a Node

Hi All,

I create a qMRMLNodeComboBox using following code:

self.outputSelector = slicer.qMRMLNodeComboBox()
self.outputSelector.nodeTypes = ["vtkMRMLModelNode"]
self.outputSelector.selectNodeUponCreation = True
self.outputSelector.addEnabled = True
self.outputSelector.removeEnabled = True
self.outputSelector.noneEnabled = True
self.outputSelector.renameEnabled = True
self.outputSelector.showHidden = False
self.outputSelector.showChildNodeTypes = False
self.outputSelector.setMRMLScene(slicer.mrmlScene)

After creating manually a new Model from UI, I try to make the model visible by using:

node = slicer.util.getNode(‘Model’)
d = node.GetDisplayNode()

but type(d) = NoneType

I am not sure how can I make it visible.

Thanks

After you add a data node to the scene and set its content, you need to add display node to show it in views. The simplest is to call CreateDefaultDisplayNodes().

2 Likes