diff --git a/configuration/macros.cfg b/configuration/macros.cfg index 45d3d17d3..288239a6c 100644 --- a/configuration/macros.cfg +++ b/configuration/macros.cfg @@ -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 %} @@ -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