From 03568b52009c89d4a7e414d86679ca8a8322a1ae Mon Sep 17 00:00:00 2001 From: raistlin7447 Date: Mon, 29 Jun 2026 19:12:12 -0600 Subject: [PATCH] fix: slicing fails when filament_end_gcode uses layer_z with a wipe tower (#14462) WipeTowerIntegration::append_tcr processed filament_end_gcode with only layer_num in its placeholder config, so a filament_end_gcode referencing {layer_z} could not be evaluated and slicing aborted. This affects any multi-filament print that routes tool changes through the prime/wipe tower (for example a support filament on a Bambu printer); the same macro works in machine_end_gcode and on the non-wipe-tower set_extruder path, which both define layer_z. Set layer_z to tcr.print_z, the value this function already provides to its change_filament_gcode and tcr_rotated_gcode placeholders. Fixes #10119 --- src/libslic3r/GCode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ba9120d3bd..80b9cb47ee 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -781,6 +781,7 @@ static std::vector get_path_of_change_filament(const Print& print) if (gcodegen.writer().filament() != nullptr && !filament_end_gcode.empty()) { DynamicConfig config; config.set_key_value("layer_num", new ConfigOptionInt(gcodegen.m_layer_index)); + config.set_key_value("layer_z", new ConfigOptionFloat(tcr.print_z)); if (!gcodegen.m_filament_instances_code.empty()) { end_filament_gcode_str += ("M624 " + gcodegen.m_filament_instances_code + "\n"); gcodegen.m_filament_instances_code = "";