# Can't hide rulers from specific 3d Views (with python)

**URL:** https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059
**Category:** Support
**Created:** [November 7, 2019, 1:59pm UTC](https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059 "2019-11-07T13:59:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Brian\_N](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@Brian\_N](https://discourse.slicer.org/u/Brian_N)
#### Post date: [November 7, 2019, 1:59pm UTC](https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059/1 "2019-11-07T13:59:10Z")

</div>

I’m having trouble displaying an Annotation Ruler in only certain 3D views.

For example, when using the Dual 3D Layout, I quickly create both a Fiducial and Ruler. If I input the following up the python interactor, the Fiducial disappears from the second 3D view (as expected):

`getNode('vtkMRMLMarkupsFiducialNode1').GetDisplayNode().AddViewNodeID('vtkMRMLViewNode1')`

However, if I input the following for the AnnotationRulerNode, the ruler does not disappear from the second 3D View:

`getNode('vtkMRMLAnnotationRulerNode1').GetDisplayNode().AddViewNodeID('vtkMRMLViewNode1')`

The ruler node actually has 3 display nodes, so I tried it on all 3, but it still did not work:

`getNode('vtkMRMLAnnotationRulerNode1').GetNthDisplayNode(0).AddViewNodeID('vtkMRMLViewNode1')`  
`getNode('vtkMRMLAnnotationRulerNode1').GetNthDisplayNode(1).AddViewNodeID('vtkMRMLViewNode1')`  
`getNode('vtkMRMLAnnotationRulerNode1').GetNthDisplayNode(2).AddViewNodeID('vtkMRMLViewNode1')`

And finally, the ruler automatically appears under a hierarchy, so I also tried the following, but again without success:

`getNode('vtkMRMLAnnotationHierarchyNode2').GetDisplayNode().AddViewNodeID('vtkMRMLViewNode1')`  
`getNode('vtkMRMLAnnotationHierarchyNode1').GetDisplayNode().AddViewNodeID('vtkMRMLViewNode1')`

I also removed the ruler from the hierarchy, and tried all of the above, but it did not work. Is there something I am missing, or is this a bug in Slicer?

Thanks,  
Brian

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [November 7, 2019, 2:01pm UTC](https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059/2 "2019-11-07T14:01:28Z")

</div>

You may try calling `RemoveAllViewNodeIDs` before adding node IDs.

Annotation rulers are being phased out. In recent Slicer Preview Releases you can use Markups lines instead.

---

<div class="post-metadata">

### Author: ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)
#### Post date: [November 7, 2019, 2:45pm UTC](https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059/3 "2019-11-07T14:45:30Z")

</div>

Hi Brian,

I encountered the same case not long before. I did a silly way to go through all rulers and check their names to let decide show or hide:

```
  value = 0 # hide
  value = 1 # show
  for i in range(NumofRulers):
        nodeName = 'Line-Ruler_No'+str(i+1) # ruler Node's name
        node = slicer.util.getNode(nodeName)
        if node:
             node.SetDisplayVisibility(value)

```

Hope it helps.

---

<div class="post-metadata">

### Author: ![Brian\_N](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@Brian\_N](https://discourse.slicer.org/u/Brian_N)
#### Post date: [November 11, 2019, 1:21pm UTC](https://discourse.slicer.org/t/cant-hide-rulers-from-specific-3d-views-with-python/9059/4 "2019-11-11T13:21:27Z")

</div>

Thanks. I ended up using Markup Lines, and everything works as expected
