Skip to content

Commit

Permalink
SPE-1776: Stop backward adding M104 lines when commands G28/G29 are f…
Browse files Browse the repository at this point in the history
…ound, during postprocessing gcode
  • Loading branch information
enricoturri1966 authored and lukasmatena committed Jun 14, 2023
1 parent cb6262c commit 1338b78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1338b78

Please sign in to comment.