SPE-1922: Place M600 after unretract to prevent printer returns at the position that was already printed with the previous color.

This fixes #2672 caused by the default implementation of M600 that returns back to XY position before M600.
This commit is contained in:
Nohus 2022-10-13 06:01:20 +02:00 committed by Lukáš Hejl
parent 76bbfbad5f
commit 540b800a5c
2 changed files with 15 additions and 1 deletions

View File

@ -2249,7 +2249,13 @@ LayerResult GCodeGenerator::process_layer(
if (single_object_instance_idx == size_t(-1)) {
// Normal (non-sequential) print.
gcode += ProcessLayer::emit_custom_gcode_per_print_z(*this, layer_tools.custom_gcode, m_writer.extruder()->id(), first_extruder_id, print.config());
std::string custom_gcode = ProcessLayer::emit_custom_gcode_per_print_z(*this, layer_tools.custom_gcode, m_writer.extruder()->id(), first_extruder_id, print.config());
if (layer_tools.custom_gcode != nullptr && layer_tools.custom_gcode->type == CustomGCode::ColorChange) {
// We have a color change to do on this layer, but we want to do it immediately before the first extrusion instead of now, in order to fix GH #2672
m_pending_pre_extrusion_gcode = custom_gcode;
} else {
gcode += custom_gcode;
}
}
// Extrude skirt at the print_z of the raft layers and normal object layers
// not at the print_z of the interlaced support material layers.
@ -3010,6 +3016,12 @@ std::string GCodeGenerator::_extrude(
// compensate retraction
gcode += this->unretract();
if (!m_pending_pre_extrusion_gcode.empty()) {
// There is G-Code that is due to be inserted before an extrusion starts. Insert it.
gcode += m_pending_pre_extrusion_gcode;
m_pending_pre_extrusion_gcode.clear();
}
// adjust acceleration
if (m_config.default_acceleration.value > 0) {
double acceleration;

View File

@ -458,6 +458,8 @@ private:
bool m_brim_done;
// Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
bool m_second_layer_things_done;
// G-code that is due to be written before the next extrusion
std::string m_pending_pre_extrusion_gcode;
// Pointer to currently exporting PrintObject and instance index.
GCode::PrintObjectInstance m_current_instance;