Measuring diameter of workpieces with longitudinal grooves