@dc42 and @mwolter Thank you both for your help.
As I mentioned conditionals are not my forte.
I eventually got it working and am pleased with what it does.
I include it for anyone else, even the original above by @mwolter would work but tweaked what I knew I could tweak, namely I used 4 screw locations instead of 3.
This is for a RailCore II CoreXY with 3 Z motors but could probably be applied to anything else.
New bed.g
; New 2/5/2020
if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it
M98 P"0:/sys/homex.g" ; home x
M98 P"0:/sys/homey.g" ; home Y
M98 P"0:/sys/homez.g" ; home z
;
M561 ; clear any bed transform
;M558 P9 H5 F120 T24000 ; increase dive height
M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming
;
echo "Bed Traming Cycle: 1 - Difference was " ^ move.calibration.initial.deviation ^ "mm"
;
while move.calibration.initial.deviation >= 0.02 ; perform additional tramming if previous deviation was over 0.02mm
if iterations = 5
abort "Too many auto tramming attempts"
M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming
echo "Bed Traming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm"
continue
;
;M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config
G28 Z ; home z
bed_Fourscrews.g
G30 P0 X15 Y45 Z-99999
G30 P1 X15 Y275 Z-99999
G30 P2 X275 Y275 Z-99999
G30 P3 X275 Y45 Z-99999 S3
If you make it better, please let me know so I can implement it also!
Regards,
Paul