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
This commit is contained in:
raistlin7447
2026-06-29 19:12:12 -06:00
committed by GitHub
parent 3cf0f4dba5
commit 03568b5200

View File

@@ -781,6 +781,7 @@ static std::vector<Vec2d> 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 = "";