Use diag_pin to detect obstacle on bed and set offset in IDEX printer

Basic Information:

Printer Model: custom IDEX - hybrid corexy
MCU / Printerboard: Monster8 V2.0

Hi all. I just build an IDEX printer with hybrid corexy kinematics. I found it tricky to calibrate the offset between the 2 nozzles and though of automating it. At the very back of the bed I have a screw head poking above the bed, with a known diameter
So the idea is to drive the nozzle of each toolhead untill it collides with the screw head and use the reported X positions (+screw diameter) to calculate the offset.

The problem is I am not sure if this is possible. So instruct klipper to move until the diag_pin is triggered but without using the G28 command for homing. Has anyone done something similar?

You can try to adopt this working solution based on optical switches and macros.