diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 33d3960d87..db087a9bad 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -11,6 +11,8 @@ #include "BoundingBox.hpp" #include "LocalesUtils.hpp" +#include + namespace Slic3r { @@ -170,12 +172,18 @@ public: m_gcode += set_format_F(f); } + // Append newline if at least one of X,Y,E,F was changed. + // Otherwise, remove the "G1". + if (! boost::ends_with(m_gcode, "G1")) + m_gcode += "\n"; + else + m_gcode.erase(m_gcode.end()-2, m_gcode.end()); + m_current_pos.x() = x; m_current_pos.y() = y; // Update the elapsed time with a rough estimate. m_elapsed_time += ((len == 0.f) ? std::abs(e) : len) / m_current_feedrate * 60.f; - m_gcode += "\n"; return *this; }