Don't fake unretract after M600 but reset the retraction data properly.

supermerill/SuperSlicer#2295
This commit is contained in:
supermerill 2022-02-01 21:08:55 +01:00
parent d423e303e3
commit 994997ab90
3 changed files with 12 additions and 2 deletions

View File

@ -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
{

View File

@ -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; }

View File

@ -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