Skip to content

Commit

Permalink
MACRO: only retract at end print if extruder can extrude (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeKeck authored Dec 27, 2024
1 parent bd92c4d commit 42ca90d
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions configuration/macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,13 @@ gcode:

[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode:
# IDEX mode
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}

# Calculate safe Z position
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
Expand All @@ -1299,14 +1306,30 @@ gcode:
{% set z_safe = max_z - current_z %}
{% endif %}

# Can extruder extrude
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}

# Relative positioning
G91
# Retract the filament a bit before lifting the nozzle.
G1 E-2 F3600
{% if can_extrude %}
G1 E-2 F3600
{% endif %}
# Move to safe Z position
G0 Z{z_safe} F3600
# Retract filament even more
G1 E-{(r-2)} F3600
{% if can_extrude %}
G1 E-{(r-2)} F3600
{% endif %}
# Back to absolute positioning
G90

Expand Down

0 comments on commit 42ca90d

Please sign in to comment.