From f94794cf0f8c1f64f88f3a9a34494f814dc72639 Mon Sep 17 00:00:00 2001 From: solutionphil Date: Fri, 4 Sep 2026 01:00:51 +0200 Subject: [PATCH] Make the toolchange retract relative, whatever mode the slicer is in PHROZEN_TOOLCHANGE opens with `G1 E-1 F3600`, and nothing above it sets the extrusion mode. In M83 that is the 1 mm retract it reads as. In M82 it means "move E to absolute position -1", which mid-print is a retract of everything extruded since the last G92. Klipper does not stop that. max_extrude_only_distance is 3000 on this printer -- Phrozen raised it from the 50 mm default -- so the move is well inside the limit and is carried out. No error, no message: the filament is pulled clear of the extruder and the rest of the job prints air. WHO IS EXPOSED. The Orca profile we ship sets use_relative_e_distances 1, so nobody following the manual meets this. It is reachable with a slicer or a profile that emits absolute E -- which is Cura's default -- and it fires at every colour change once it does. The three other bare E moves in this file, in LOAD_FILAMENT and UNLOAD_FILAMENT, all set M83 first; this was the only one that did not. The mode is read from printer.gcode_move.absolute_extrude, checked present on a running printer rather than assumed. Jinja renders before the first command runs, so the value is the mode on entry -- correct here because nothing above the read changes it, unlike a QUERY_ENDSTOPS read in the same macro. Rendered both ways against Klipper's own jinja2: absolute gives M83 / retract / M82, relative gives M83 / retract / a comment-only line. DELIVERY. The macro sits inside #@FEAT auto_mode, and the merge adds and removes whole blocks -- it never rewrites one a printer already has, so an edit in place would reach fresh flashes and nowhere else. #@DROP is no help either: it refuses a section a block already owns. So the corrected block ships as auto_mode2 and auto_mode is retired in the same run, the way g30 -> g30_meshdone shipped. The pairing is enforced by addon_merge, not trusted: if the block cannot be added the retirement does not run, so the two print macros this block carries cannot go missing. Verified against the real AddOn.cfg of a running printer, processed by that printer's own installed merge: retired 1, merged 1, PHROZEN_TOOLCHANGE and PHROZEN_AMS_START each present exactly once afterwards, the retract carrying its M83, and a second run reporting nothing to do. Co-Authored-By: Claude Opus 5 --- README.html | 2 +- README.md | 2 +- config-templates/AddOn.cfg.template | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.html b/README.html index 9136695..08352e6 100644 --- a/README.html +++ b/README.html @@ -985,7 +985,7 @@

OrcaSlicer — multicolor cell. G30 then loads your saved phrozen mesh instantly — calibrating and saving it the first time, if none exists yet. Homing is automatic. It needs the -auto_mode and ams features in +auto_mode2 and ams features in AddOn.cfg, both on by default, and the gcode_shell_command extension.

diff --git a/README.md b/README.md index 01d6eaa..2e4732b 100644 --- a/README.md +++ b/README.md @@ -498,7 +498,7 @@ colour** — otherwise a long print changes shade partway through, and nothing w The start G-code heats the **bed straight to print temperature** and holds the **nozzle at a probe-safe 140 °C** through home and probe, so it cannot ooze onto the load cell. **`G30`** then loads your saved `phrozen` mesh instantly — calibrating and saving it the first time, if none exists yet. Homing is -automatic. It needs the `auto_mode` and `ams` features in `AddOn.cfg`, both on by default, and the +automatic. It needs the `auto_mode2` and `ams` features in `AddOn.cfg`, both on by default, and the `gcode_shell_command` extension. diff --git a/config-templates/AddOn.cfg.template b/config-templates/AddOn.cfg.template index 686f308..5a58c91 100644 --- a/config-templates/AddOn.cfg.template +++ b/config-templates/AddOn.cfg.template @@ -773,7 +773,14 @@ gcode: #@RETIRE ams | AMS on/off switch - the AMS is detected now, so there is nothing to declare # -#@FEAT auto_mode | Orca auto AMS-mode: reads the 'ams' flag -> P0 M1/M2/M3 at print start +# PHROZEN_TOOLCHANGE lives inside this block, and a change *inside* a block reaches fresh flashes +# and nowhere else -- the merge adds and removes whole blocks, it never rewrites one a printer +# already has. So the corrected macro ships under a new id and the old block is retired in the same +# run, under the same backup, exactly as the g30 -> g30_meshdone replacement did. The pairing is +# enforced by addon_merge, not trusted: if this block cannot be added, the retirement does not run, +# so the two print macros this block carries can never go missing. +#@RETIRE auto_mode | replaced by auto_mode2, which fixes a retract that assumed relative E +#@FEAT auto_mode2 | Orca auto AMS-mode: reads the 'ams' flag -> P0 M1/M2/M3 at print start # ───── Flag-driven AMS mode for OrcaSlicer (Arco Unleashed) ───── # The 'ams' flag follows the AMS device node, kept in step by [arco_tool_gate] -- nobody sets # it, and there is nothing to remember to set. This macro reads it at print start and applies @@ -834,7 +841,15 @@ gcode: [gcode_macro PHROZEN_TOOLCHANGE] description: Per color change - AMS spit (P10) if AMS on, else pause for a manual swap gcode: + # The retract has to be a RELATIVE one. Without this, the line means "move E to the absolute + # position -1" whenever the slicer is in M82 -- mid-print that is a retract of everything + # extruded since the last G92, and max_extrude_only_distance is 3000 on this printer, so + # Klipper carries it out instead of refusing it. Jinja renders before the first command runs, + # so this reads the mode as it was on entry; nothing above it changes the mode. + {% set was_abs_e = printer.gcode_move.absolute_extrude %} + M83 G1 E-1 F3600 ; small retract, like the official profile + {% if was_abs_e %}M82{% endif %} ; hand the slicer back the mode it was using {% set ams = printer.save_variables.variables.ams|default(0)|int %} {% if ams %} {% set f = params.FLUSH|default(0)|float %}