From 5c73f0b1c84de7de3b46abd10dd1e5237946688d Mon Sep 17 00:00:00 2001 From: Clifford Garwood Date: Thu, 27 Aug 2026 10:36:15 -0400 Subject: [PATCH] refactor(gcode): drop the wipe tower's unreachable preheat rewrite append_tcr2 scanned the tower's G-code for a "preheat T" comment and rewrote its S value to the interface temperature. Nothing it could match was ever there. That comment has exactly one producer, GCodeProcessor's backtrace injector, and that runs inside run_post_process() -- a pass over the finished, exported file. append_tcr2 runs while the file is still being generated, so the text it looked for did not exist yet and could not. The loop therefore walked every line, matched none, and swapped the string for an identical copy. Delete it. Co-Authored-By: Claude Opus 5 (1M context) --- src/libslic3r/GCode.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index eead777c3c..f339fb8611 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1679,44 +1679,6 @@ static std::vector get_path_of_change_filament(const Print& print) toolchange_gcode_str.swap(out); } - if (toolchange_temp_override > 0) { - const std::string preheat_token = "preheat T" + std::to_string(new_extruder_id); - const int preheat_temp = interface_temp > 0 ? interface_temp : toolchange_temp_override; - std::string out; - out.reserve(tcr_rotated_gcode.size()); - size_t pos = 0; - while (pos < tcr_rotated_gcode.size()) { - size_t line_end = tcr_rotated_gcode.find('\n', pos); - if (line_end == std::string::npos) - line_end = tcr_rotated_gcode.size(); - std::string line = tcr_rotated_gcode.substr(pos, line_end - pos); - std::string trimmed = line; - trimmed.erase(0, trimmed.find_first_not_of(" \t")); - const bool is_preheat_line = (trimmed.find(preheat_token) != std::string::npos); - if (is_preheat_line) { - // Preserve early-preheat timing while forcing interface temp for contact toolchanges. - size_t s_pos = trimmed.find('S'); - if (s_pos != std::string::npos) { - size_t s_end = trimmed.find_first_not_of("0123456789", s_pos + 1); - trimmed.replace(s_pos + 1, - (s_end == std::string::npos ? trimmed.size() : s_end) - (s_pos + 1), - std::to_string(preheat_temp)); - // Reapply left indentation from the original line. - size_t line_prefix = line.find_first_not_of(" \t"); - if (line_prefix != std::string::npos) - line = line.substr(0, line_prefix) + trimmed; - else - line = trimmed; - } - } - out.append(line); - if (line_end < tcr_rotated_gcode.size()) - out.push_back('\n'); - pos = line_end + 1; - } - tcr_rotated_gcode.swap(out); - } - if (toolchange_temp_override > 0 && interface_temp > 0) { const std::string t_token = " T" + std::to_string(new_extruder_id); std::string out;