From f1ef8a013f895e6c9b72b02e22f9af10965c5809 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 15 Apr 2021 16:29:30 +0200 Subject: [PATCH] After issuing the color change custom G-code, which is most likely just M600, reset the internal retract counter, so that a retract will happen after the firmware returns from M600 to the initial position. Fixes "Blobs on print after manual color change #6362" --- src/libslic3r/GCode.cpp | 7 ++++++- src/libslic3r/GCode.hpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index efcf9610b..ae7c73542 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1905,6 +1905,7 @@ std::vector GCode::sort_print_object_instances( } std::string GCode::emit_custom_gcode_per_print_z( + GCode &gcodegen, const CustomGCode::Item *custom_gcode, // ID of the first extruder printing this layer. uint16_t first_extruder_id, @@ -1966,6 +1967,10 @@ std::string GCode::emit_custom_gcode_per_print_z( } else { gcode += print.config().color_change_gcode;//ColorChangeCode; gcode += "\n"; + //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(); } } else { if (gcode_type == CustomGCode::PausePrint) // Pause print @@ -2186,7 +2191,7 @@ void GCode::process_layer( if (single_object_instance_idx == size_t(-1)) { // Normal (non-sequential) print. - gcode += this->emit_custom_gcode_per_print_z(layer_tools.custom_gcode, first_extruder_id, print, print_stat); + gcode += this->emit_custom_gcode_per_print_z(*this, layer_tools.custom_gcode, first_extruder_id, print, print_stat); } // 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. diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 7562f5306..9559a8a6b 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -183,7 +183,7 @@ public: static void append_full_config(const Print& print, std::string& str); // called by porcess_layer, do the color change / custom gcode - std::string emit_custom_gcode_per_print_z(const CustomGCode::Item* custom_gcode, uint16_t first_extruder_id, const Print& print, PrintStatistics& stats); + std::string emit_custom_gcode_per_print_z(GCode& gcodegen, const CustomGCode::Item* custom_gcode, uint16_t first_extruder_id, const Print& print, PrintStatistics& stats); // Object and support extrusions of the same PrintObject at the same print_z. // public, so that it could be accessed by free helper functions from GCode.cpp