Change tool at minimum distance from workpiece