I have an MK3s + MMU2S, and I currently have working gcode in the "After print job is cancelled" that unloads filament, parks, and turns everything off.
The issue is if I cancel a print before the filament is loaded, the printer has to load the filament, then unload due to the way the unload filament command works. (it also has to finish heating up, which would be nice to cancel out of, but I'm less worried about that)
I want to put an if statement around the unload code so that if the printer hasn't started the first layer it will just park and turn everything off.
I was thinking I might be able to use the placeholder {__progress}, which is 0 if not available, to do this but the code below isn't working. Placeholder Documentation
G1 Y180 Z+50 F2000
{% if {__progress} is 0 %}
M702 C ; Unload filament
{% endif %}
M140 S0 ; turn off heatbed
M107 ; turn off fan
M104 S0 ; turn off temperature
M84 ; disable motors
I'm not sure if the if statement is set up wrong and/or if I can't use the progress placeholder in this way, so any guidance is appreciated.
The documentation you've linked is for the events system, not the gcode scripts, they aren't the same. Variables used in the scripts are defined here in the docs, unfortunately it doesn't look like your use case is available.
I was thinking I could use last_position_y instead and either check for a none value if the print hasn't homed yet, or check for the value to be < 0 which would mean it is probably waiting to heat up at the Y-3 before it starts its initial load and extrude gcode. However neither statement works.
Doesn't work:
{% if last_position.y is not none %}
M702 C ; Unload filament
{% endif %}
M140 S0 ; turn off heatbed
M107 ; turn off fan
M104 S0 ; turn off temperature
M84 ; disable motors
Also doesn't work:
{% if last_position.y < 0 %}
It gets hung up on the if statement and never reaches the turn off commands but the printer goes back to "Operational" and that is obviously a big problem.
I can't find any documentation on what kind of comparators are allowed in the if statements. Any thoughts on why my if statements aren't working?