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

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):


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


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


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


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?


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.

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:

Hope it helps.

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

1 Like