diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index a5c1a66b08..c9a2ef2549 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5981,7 +5981,7 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string m_wipe.reset_path();*/ Point last_post_before_retract = this->last_pos(); - gcode += this->retract(false, false, lift_type); + gcode += this->retract(false, false, lift_type, role); // When "Wipe while retracting" is enabled, then extruder moves to another position, and travel from this position can cross perimeters. // Because of it, it is necessary to call avoid crossing perimeters again with new starting point after calling retraction() // FIXME Lukas H.: Try to predict if this second calling of avoid crossing perimeters will be needed or not. It could save computations. @@ -6183,7 +6183,7 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp return true; } -std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType lift_type) +std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType lift_type, ExtrusionRole role) { std::string gcode; @@ -6201,7 +6201,8 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li (the extruder might be already retracted fully or partially). We call these methods even if we performed wipe, since this will ensure the entire retraction length is honored in case wipe path was too short. */ - gcode += toolchange ? m_writer.retract_for_toolchange() : m_writer.retract(); + if (role != erTopSolidInfill || EXTRUDER_CONFIG(retract_on_top_layer)) + gcode += toolchange ? m_writer.retract_for_toolchange() : m_writer.retract(); gcode += m_writer.reset_e(); // Orca: check if should + can lift (roughly from SuperSlicer) diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 843b4a39da..5f92fd6237 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -223,7 +223,7 @@ class GCode { std::string travel_to(const Point& point, ExtrusionRole role, std::string comment, double z = DBL_MAX); bool needs_retraction(const Polyline& travel, ExtrusionRole role, LiftType& lift_type); - std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::NormalLift); + std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::NormalLift, ExtrusionRole role = erNone); std::string unretract() { return m_writer.unlift() + m_writer.unretract(); } std::string set_extruder(unsigned int extruder_id, double print_z, bool by_object=false); bool is_BBL_Printer(); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index f76029d2ee..c07eaa70ac 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -148,6 +148,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "retraction_minimum_travel", "retract_before_wipe", "retract_when_changing_layer", + "retract_on_top_layer", "retraction_length", "retract_length_toolchange", "z_hop", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b93e7920d3..d7812e6b42 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3711,6 +3711,12 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionBools { false }); + def = this->add("retract_on_top_layer", coBools); + def->label = L("Retract on top layer"); + def->tooltip = L("Force a retraction on top layer. Disabling could prevent clog on very slow patterns with small movements, like Hilbert curve"); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBools { true }); + def = this->add("retraction_length", coFloats); def->label = L("Length"); def->full_label = L("Retraction Length"); @@ -5371,7 +5377,7 @@ void PrintConfigDef::init_fff_params() // BBS: floats "wipe_distance", // bools - "retract_when_changing_layer", "wipe", + "retract_when_changing_layer", "retract_on_top_layer", "wipe", // percents "retract_before_wipe", "long_retractions_when_cut", @@ -5423,7 +5429,7 @@ void PrintConfigDef::init_extruder_option_keys() "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", "retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", + "retract_when_changing_layer", "retract_on_top_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut" }; @@ -5436,6 +5442,7 @@ void PrintConfigDef::init_extruder_option_keys() "retract_lift_enforce", "retract_restart_extra", "retract_when_changing_layer", + "retract_on_top_layer", "retraction_distances_when_cut", "retraction_length", "retraction_minimum_travel", @@ -5455,7 +5462,7 @@ void PrintConfigDef::init_filament_option_keys() "filament_diameter", "min_layer_height", "max_layer_height", "retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", + "retract_when_changing_layer", "retract_on_top_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/ }; @@ -5468,6 +5475,7 @@ void PrintConfigDef::init_filament_option_keys() "retract_lift_enforce", "retract_restart_extra", "retract_when_changing_layer", + "retract_on_top_layer", "retraction_distances_when_cut", "retraction_length", "retraction_minimum_travel", diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index e5255d3537..18f007a40a 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1239,6 +1239,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloat, resolution)) ((ConfigOptionFloats, retraction_minimum_travel)) ((ConfigOptionBools, retract_when_changing_layer)) + ((ConfigOptionBools, retract_on_top_layer)) ((ConfigOptionFloat, skirt_distance)) ((ConfigOptionInt, skirt_height)) ((ConfigOptionInt, skirt_loops)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index b87e98c10e..8d5cbf1c7e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -4322,6 +4322,7 @@ if (is_marlin_flavor) optgroup->append_single_option_line("deretraction_speed", "", extruder_idx); optgroup->append_single_option_line("retraction_minimum_travel", "", extruder_idx); optgroup->append_single_option_line("retract_when_changing_layer", "", extruder_idx); + optgroup->append_single_option_line("retract_on_top_layer", "", extruder_idx); optgroup->append_single_option_line("wipe", "", extruder_idx); optgroup->append_single_option_line("wipe_distance", "", extruder_idx); optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx); @@ -4538,7 +4539,7 @@ void TabPrinter::toggle_options() // user can customize other retraction options if retraction is enabled //BBS bool retraction = have_retract_length || use_firmware_retraction; - std::vector vec = { "z_hop", "retract_when_changing_layer" }; + std::vector vec = {"z_hop", "retract_when_changing_layer", "retract_on_top_layer"}; for (auto el : vec) toggle_option(el, retraction, i);