Here it is, my macro:
ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Code "G53 G00 Z-1" 'Move the tool all the way up
While IsMoving()
Wend
ZOld = Getdro(2)
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
HitOld = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G53 G00 Z-1"'Z move all way up
Code "G53 G00 X65 Y-200" 'Move to change tool position
While IsMoving()
Wend
MsgBox ("Insert the new tool")
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
HitNew = GetVar(2002) 'Get the Position that the Porbe hit at
Diff = HitOld - HitNew
DiffABS =Abs(Diff)
If DiffABS=0 Then End
ZNew=0
If HitOld < HitNew Then ZNew = ZOld - DiffABS :A=1
If HitOld > HitNew Then ZNew = ZOld + DiffABS :A=2
Code "G53 G00 Z-1"
While IsMoving()
Wend
Call setdro(2,ZNew)
'FxModel Creation
End
You have to set in mach3 the position of the tool switch
It's not perfect yet, when I change the tool it remain out of 0.5/1mm but i think it's a switch problem.
I'll try to get 3-4 measure value, for the same tool and then keep the average value.
I'll be in vacation for another week so if I won't answer you know why

Bye Faby
FxModel Team