Ruler in (orthographic) 3D view

Operating system: Win 7 64 bit
Slicer version: 4.10.0
Expected behavior: Ruler button in 3D view inserts ruler into (orthographic) 3D view
Actual behaviour:
Neither “thin” nor “thick” ruler makes a ruler appear. The ruler menu item is marked as active, though.
Toggling between perspective and orthographic view doesn’t help, either.
Nor does showing/hiding the 3D cube and/or axis labels make the ruler appear.

This is probably a rarely used feature, and probably a measurement between two points of interest serves most purposes better. But in this case I simply need a rough size marker in a 3D scene, and so a ruler similar to those in the slice views would be perfect.

Am I missing something or is the feature simply broken at the moment?


1 Like

It was a user error. :confounded:
Literally moments after posting this, I realized that a white ruler on white background simply can’t be seen. So I reset my 3D background to the blue default, and there it is.

It would be nice, however, if the ruler would adapt to the background color (i.e. being drawn in black if the background is white).


Indeed. Just 10 minutes ago I was struggling to read the length measurement of a ruler:

The current state of the module that also contains the ruler functionality (i.e. Annotations) is that it’s deprecated, and thus not maintained, especially considering convenience features such as this. There has been quite a push to re-create annotation tools (ruler, angle measurement, even splines) recently, but it has proven to be technologically quite challenging (due to the VTK widget infrastructure). Hopefully in the next several months there can be some progress made on this. Fingers crossed!

Btw thanks for reporting the issue and also following up on it.

Just to clarify, @cpinter referred to annotation ruler as not maintained.

View rulers (see below) are stable and fully maintained.


We could make them appear with shadowing to make them visible over both dark and bright background - I’ve added a feature request for this. Most likely it will be implemented if more users ask for it, a funded project will need it, or somebody volunteers his/her time to implement it and send a pull request.

1 Like

Thanks @cpinter and @lassoan.
Yes, I was referring to the view ruler/scale as shown in @lassoan’s reply.
Shadowing seems a good solution.

@cpinter @lassoan a quick question about the 3D-view ruler:

Right after I do " threeDView.resetFocalPoint() " in python, I would like to have a ruler scaled in the same level as all other 3-slice-views. Say, in the slice-viewers, I have a ruler of 5mm, then I would like to have a same one in the 3D-viewer. So via python, is there a way to automatically set up the ruler in the 3D-viewer to match them inside the slice-viewers?

Thanks a lot.

You can add an observer to the slice node and whenever it is changed, run this script:

# Get scale factor from slice view
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
sliceNodeFovMm = sliceNode.GetFieldOfView()[1]
sliceNodeFovPixels = sliceNode.GetDimensions()[1]
viewScaleMmPerPixel = sliceNodeFovMm/float(sliceNodeFovPixels)

# Set scale factor in 3D view
threeDview =
viewHeightPixels = threeDview.renderWindow().GetSize()[1]
cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDview.mrmlViewNode())
viewHeightMm = viewHeightPixels * viewScaleMmPerPixel

Thank you so much. It works wonderfully well after I just set up a connection:

layoutManager =

def autoZoomOf3DViewer(self):
      #old_layout = = slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView

      # Get scale factor from slice view
      sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
      sliceNodeFovMm = sliceNode.GetFieldOfView()[1]
      sliceNodeFovPixels = sliceNode.GetDimensions()[1]
      viewScaleMmPerPixel = sliceNodeFovMm/float(sliceNodeFovPixels)

      # Set scale factor in 3D view threeDview==>threeDView
      threeDView =
      viewHeightPixels = threeDView.renderWindow().GetSize()[1]
      cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDView.mrmlViewNode())
      viewHeightMm = viewHeightPixels * viewScaleMmPerPixel
1 Like

I’m trying to put the ruler bar, but the scale of the ruler is wrong (the whole animal has about 5cm and when I try zooming at one piece of the animal (p.e. cranial bones), the software shows them as 25cm). How can I adjust it?

Slicer reports whatever is in the data. There is no calibration of the ruler. You need to correct the scale of the data. If this is a 3D volume, go to volumes module and check the image spacing and cross-reference to the known pixel spacing of the data.

If it is a 3D model given to you, you need to find what units those were in…

Thank you. It is a reconstruction 3D that I did from the slices (2D images), I know the pixel resolution is 9, but I don’t know the image spacing. I didn’t find the cross-reference in the software too (just the image dimensions, spacing and origin)

In most cases pixel resolution is the same as image spacing. How you tried putting 0.009, 0.009, 0.009 as your image spacing in the volumes module and see if the ruler issue gets corrected.

It didn’t work. There is no difference in the ruler bar. The pixel size is 8.72, so I wrote 0.008, 0.008, 0.008, nothing changed. Then I tried with 0.00872, the same result, so I wrote 0.009 and also nothing changed.

Did you reset the field of view after you change the spacing? Alternatively, you can toggle the visibility of the volume in the Data module for the changes to take effect.

Yes, I did. Nothing changed. I’m using a TIFF file and one NRRD file, none of them I can change the ruler bar. I also tried in a DCM file, and the result was the same.

There must be something amiss in the steps: This is a sample data from Slicer, which has slice spacing of 1,1,1.3mm. I made a clone of this, and edited the image spacing to be 0.5, 0.5, 0.625 (half of the original), and then hit the FOV button and you can see the ruler is different and scaled correctly. I suspect you are missing a step in between. Perhaps try with the same data first, and see that it works.

It worked in 2D images!
I realized that I didn’t do one step you told me to (hit the FOV button).
Thank you so much.


But I tried for 3D model, and it didn’t work. Do you know what could be?

You have to be in the orthographic projection for ruler to show in 3d view. You are probably in perspective rendering mode.

No, I’m in the orthographic projection already. The ruler bar in 2D imagens shows correctly the scale (for example 5mm), but the reconstruction of the structure shows 25cm, for example.
The same occurs when I’m using the ruler to measures structures in the 3D model.