diff --git a/src/libslic3r/Extruder.cpp b/src/libslic3r/Extruder.cpp index cfbd5a248..1edad1857 100644 --- a/src/libslic3r/Extruder.cpp +++ b/src/libslic3r/Extruder.cpp @@ -77,6 +77,14 @@ double Tool::unretract() return dE; } +// Called after a M600 or somethgin like that, so you don't have to unretract, but the absolute position won't change. +void Tool::reset_retract() { + m_retracted = 0.; + m_restart_extra = 0.; + if (m_restart_extra_toolchange != 0) + m_restart_extra_toolchange = 0.; +} + // Used filament volume in mm^3. double Tool::extruded_volume() const { diff --git a/src/libslic3r/Extruder.hpp b/src/libslic3r/Extruder.hpp index 8e1ac0f4f..9daec0dec 100644 --- a/src/libslic3r/Extruder.hpp +++ b/src/libslic3r/Extruder.hpp @@ -27,6 +27,7 @@ public: virtual double extrude(double dE); virtual double retract(double length, double restart_extra, double restart_extra_from_toolchange); virtual double unretract(); + virtual void reset_retract(); double E() const { return m_E; } void reset_E() { m_E = 0.; } double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; } diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index fa27aef47..4258f6370 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1576,7 +1576,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu } // ensure the first tool doesn't "extra_retract" - m_writer.unretract(); + m_writer.tool()->reset_retract(); //write temps after custom gcodes to ensure the temperature are good. (after tool selection) if ((initial_extruder_id != (uint16_t)-1) && !this->config().start_gcode_manual && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0) @@ -2162,7 +2162,8 @@ std::string GCode::emit_custom_gcode_per_print_z( //FIXME Tell G-code writer that M600 filled the extruder, thus the G-code writer shall reset the extruder to unretracted state after // return from M600. Thus the G-code generated by the following line is ignored. // see GH issue #6362 - gcodegen.writer().unretract(); + // merill: don't unretract, as it create problem on absolute position. Clear the retraction properley, plz. + gcodegen.writer().tool()->reset_retract(); } } else { if (gcode_type == CustomGCode::PausePrint) // Pause print