Just a simple script to report focus distance in mm. Best to set your AF settings to a small area, spot measurement. It's less accurate for large distances. Try moving your hand slowly towards the lens, there's definitely a decreasing measurement.
--[[
@title view distance
--]]
repeat
press "shoot_half"
sleep(1000)
x=get_focus()
print(x)
release "shoot_half"
sleep(1000)
until false
Expanding on this idea, it's possible with some models to use FlexiZone AF, where you can move the focus zone. This could give some 600 distance measurements on the scene, thus building a depth map. It would be more efficient to use focus stacking and turn that into a depth map.