This electronic meter can reliably measure the length of a Lego beam in a few seconds.
If the touch sensor is released, the brain measure the rotations of the motor and then compute the beam size thanks to the range block.
You can visit my website to see some photos and to download building instructions and EV3 program.
https://tomastechnic.com/beam-meter/