From 1338b78c8d3b8715093bb399f52d91180d5024a7 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 14 Jun 2023 12:16:35 +0200 Subject: [PATCH] SPE-1776: Stop backward adding M104 lines when commands G28/G29 are found, during postprocessing gcode --- src/libslic3r/GCode/GCodeProcessor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 64a49cc7e..f7fbb52a6 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -3605,14 +3605,16 @@ void GCodeProcessor::post_process() auto rev_it = m_lines.rbegin() + rev_it_dist; auto start_rev_it = rev_it; + std::string curr_cmd = GCodeReader::GCodeLine::extract_cmd(rev_it->line); // backtrace into the cache to find the place where to insert the line - while (rev_it != m_lines.rend() && rev_it->time > time_threshold_i && GCodeReader::GCodeLine::extract_cmd(rev_it->line) != cmd) { + while (rev_it != m_lines.rend() && rev_it->time > time_threshold_i && curr_cmd != cmd && curr_cmd != "G28" && curr_cmd != "G29") { rev_it->line = line_replacer(rev_it->line); ++rev_it; + curr_cmd = GCodeReader::GCodeLine::extract_cmd(rev_it->line); } - // we met the previous evenience of cmd. stop inserting lines - if (rev_it != m_lines.rend() && GCodeReader::GCodeLine::extract_cmd(rev_it->line) == cmd) + // we met the previous evenience of cmd, or a G28/G29 command. stop inserting lines + if (rev_it != m_lines.rend() && (curr_cmd == cmd || curr_cmd == "G28" || curr_cmd == "G29")) break; // insert the line for the current step