If you are aware of SVRF (Calibre) code then you can use top level Boundary layer as input parameter, use ANGLE command to get the horizontal and vertical edges, report the length of horizontal and vertical edges either by using LENGTH > 0, this would report coordinates of failing edge and then you can measure the difference between coordinates.
EXTENT command givers you a bounding box (rectangle) for the whole design (all layers).
I don't know the command to measure the sides of a rectangle - but this should be pretty basic in SVRF.