I am struggling to make post layer scripts work.
I want the machine to do a nozzle wipe after a certain number of layers, but right now I am trying to make it work after every layer.
I have found some code on bambu related forums, asked chatgpt for assistance and tried some with a p1s system.
Currently I am using this code, but it is not behaving as I would like.
; Layer Change Script
; Save current position
M114 ; Report current position
; Now add the Z-hop to avoid collision
G91 ; Set relative positioning
G1 Z1.0 F300 ; Move Z axis up by 1.0mm
; Move to wipe position
G90 ; Set absolute positioning
G1 X60 Y265 F15000 ; Move to nozzle wipe position
; Nozzle wipe procedure
G92 E0 ; Zero extruder
G1 E-0.5 F300 ; Retract filament
G1 X100 F5000 ; Wipe right
G1 X70 F15000 ; Wipe left
G1 X100 F5000 ; Wipe right
G1 X70 F15000 ; Wipe left
G1 X100 F5000 ; Wipe right
G1 X70 F15000 ; Wipe left
G1 X60 F5000 ; Clearance
; Restore previous position
G91 ; Set relative positioning
G1 Z-1.0 F300 ; Move Z axis down by 1.0mm
; Manually insert the position reported by M114 here
; Example: If M114 reported X120 Y150 Z10
G90 ; Set absolute positioning
;G1 X[last_x] Y[last_y] Z[last_z] F15000 ; Move back to previous print position (THIS BIT DOESNT WORK)
; Continue printing
__________________________________
Since the remeber last position thing doesnt work properly, the nozzle moves down in z directly after the last script command and travels back to the intended printposition while extruding as interpret it. I have destroyed one platform already so a but more careful with testing now.
Any advice on how to alter this code to work as intended?