# How to display volume node in view programatically

**URL:** <https://discourse.slicer.org/t/how-to-display-volume-node-in-view-programatically/14129>\
**Category:** Development\
**Created:** [October 19, 2020, 8:27am UTC](https://discourse.slicer.org/t/how-to-display-volume-node-in-view-programatically/14129 "2020-10-19T08:27:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [October 19, 2020, 8:27am UTC](https://discourse.slicer.org/t/how-to-display-volume-node-in-view-programatically/14129/1 "2020-10-19T08:27:39Z")

</div>

I would like to show in all view a volume node present in the subject hierarchy, just like i click on the eye.  
I work in a loadable module in c++.

I searched for this function in Slicer sources, i found it in qSlicerSubjectHierarchyVolumesPlugin.  
IE : qSlicerSubjectHierarchyVolumesPlugin::showVolumeInAllViews

But my problem is that i did not manage to link to this plugin and use this function in my code, i know how to link to the modules, but here it is a plugin in the volumes module.

So how to achieve that ? Maybe there is another way to show a volume node in all view ?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 19, 2020, 8:44am UTC](https://discourse.slicer.org/t/how-to-display-volume-node-in-view-programatically/14129/2 "2020-10-19T08:44:09Z")

</div>

One way:

```auto
    appLogic = slicer.app.applicationLogic()
    selectionNode = appLogic.GetSelectionNode()
    selectionNode.SetActiveVolumeID(backgroundVolumeNodeID)
    appLogic.PropagateVolumeSelection()

```

Another way

```auto
    numberOfCompositeNodes = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLSliceCompositeNode")
    for i in range(numberOfCompositeNodes):
      compositeNode = slicer.mrmlScene.GetNthNodeByClass(i,"vtkMRMLSliceCompositeNode")
      compositeNode.SetBackgroundVolumeID(backgroundVolumeNodeID)

```
