Telecentric lenses
Telecentric and bi-telecentric lenses keep magnification constant through the depth of field, so parts measure the same size wherever they sit. Pick by magnification (sensor size / field of view), working distance and the largest sensor you use.