The simplest way would be to put some kind of Markups points at the locations you want to measure between. This could be control points for a MarkupsCurve or a MarkupsPointList, for example. Then the coordinates of these points in physical units are easily accessible and you can just calculate the euclidean distance between them.
import numpy as np
markupsNode = getNode('MyPoints')
pos0 = np.zeros(3) # initialize variable to hold the coordinates of the first point
markupsNode.GetNthControlPointPositionWorld(0, pos0) # get coord of first point
pos1 = np.zeros(3) # initialize variable to hold coord of second point
markupsNode.GetNthControlPointPositionWorld(1, pos1) # get coord of second point
# Calculate the physical distance between these points (in millimeters because Slicer world coordinates are in mm)
distanceBetweenPointsMm = np.linalg.norm(pos1-pos2)
The placed points can be in a single slice view or placed in 3D or placed on different slices, etc., it doesn’t matter. Slicer keeps track of everything in a physical 3D spatial representation.