print(
"BeforeUnload: Script started for nozzle={} tip={}".format(
nozzle.name, nozzleTip.name))
try:
cal = nozzleTip.calibration
print("BeforeUnload: cal={} isCalibrated={}".format(cal, cal.isCalibrated(nozzle)))
# Try reset(nozzle) first, fall back to reset() with no args
try:
cal.reset(nozzle)
print("BeforeUnload: cal.reset(nozzle) succeeded")
except TypeError:
cal.reset()
print("BeforeUnload: cal.reset() (no args) succeeded")
print("BeforeUnload: isCalibrated after reset: {}".format(cal.isCalibrated(nozzle)))
print("BeforeUnload: offset after reset: {}".format(cal.getCalibratedOffset(nozzle, 0.0)))
except Exception as e:
print("NozzleTip.BeforeUnload error: {}".format(str(e)))
There's a lot of extra prints in there, I was figuring out how the scripting works while I wrote this, and you don't need them all if you're not watching the logs. But this script runs automatically at nozzle unload and resets all the calibration offsets so the machine unloads at the raw tool changer positions, just like it does when it loads the tip.
The minimal version would be:
try:
cal = nozzleTip.calibration
# Try reset(nozzle) first, fall back to reset() with no args
try:
cal.reset(nozzle)
except TypeError:
cal.reset()
except Exception as e:
print("NozzleTip.BeforeUnload error: {}".format(str(e)))