From 7bd4f85a963c73f1746a1bd6e10ff0a0f1b6e96d Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Wed, 7 May 2025 11:39:16 +0800 Subject: [PATCH] ENH: add params for filament retract when extruder change jira: STUDIO-11965 Signed-off-by: xun.zhang Change-Id: Id175e9dbce419d43cf45d6116ed4fa4fd556f606 (cherry picked from commit c7964441719f521d1a20dc9f084a7598bd01a9a5) --- .../BBL/filament/fdm_filament_common.json | 6 ++++++ src/libslic3r/GCode.cpp | 11 +++++++++++ src/libslic3r/Preset.cpp | 3 ++- src/libslic3r/PrintConfig.cpp | 16 ++++++++++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/slic3r/GUI/Tab.cpp | 6 ++++++ 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/resources/profiles/BBL/filament/fdm_filament_common.json b/resources/profiles/BBL/filament/fdm_filament_common.json index 517b5691e7..824b18b076 100644 --- a/resources/profiles/BBL/filament/fdm_filament_common.json +++ b/resources/profiles/BBL/filament/fdm_filament_common.json @@ -168,6 +168,9 @@ "nozzle_temperature_initial_layer": [ "200" ], + "long_retractions_when_ec": [ + "0" + ], "overhang_fan_speed": [ "100" ], @@ -180,6 +183,9 @@ "required_nozzle_HRC": [ "3" ], + "retraction_distances_when_ec": [ + "0" + ], "supertack_plate_temp": [ "45" ], diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index cd3be75f1d..dcb4b9a85e 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -928,6 +928,8 @@ static std::vector get_path_of_change_filament(const Print& print) gcodegen.placeholder_parser().set("current_extruder", new_filament_id); gcodegen.placeholder_parser().set("retraction_distance_when_cut", gcodegen.m_config.retraction_distances_when_cut.get_at(new_filament_id)); gcodegen.placeholder_parser().set("long_retraction_when_cut", gcodegen.m_config.long_retractions_when_cut.get_at(new_filament_id)); + gcodegen.placeholder_parser().set("retraction_distance_when_ec", gcodegen.m_config.retraction_distances_when_ec.get_at(new_filament_id)); + gcodegen.placeholder_parser().set("long_retraction_when_ec", gcodegen.m_config.long_retractions_when_ec.get_at(new_filament_id)); // Process the start filament gcode. std::string start_filament_gcode_str; @@ -2506,11 +2508,15 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato //Orca: set the key for compatibilty this->placeholder_parser().set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(initial_extruder_id)); this->placeholder_parser().set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(initial_extruder_id)); + this->placeholder_parser().set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(initial_extruder_id)); + this->placeholder_parser().set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(initial_extruder_id)); this->placeholder_parser().set("temperature", new ConfigOptionInts(print.config().nozzle_temperature)); this->placeholder_parser().set("retraction_distances_when_cut", new ConfigOptionFloats(m_config.retraction_distances_when_cut)); this->placeholder_parser().set("long_retractions_when_cut",new ConfigOptionBools(m_config.long_retractions_when_cut)); + this->placeholder_parser().set("retraction_distances_when_ec", new ConfigOptionFloatsNullable(m_config.retraction_distances_when_ec)); + this->placeholder_parser().set("long_retractions_when_ec",new ConfigOptionBoolsNullable(m_config.long_retractions_when_ec)); //Set variable for total layer count so it can be used in custom gcode. this->placeholder_parser().set("total_layer_count", m_layer_count); @@ -6896,6 +6902,8 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo // if we are running a single-extruder setup, just set the extruder and return nothing if (!m_writer.multiple_extruders) { this->placeholder_parser().set("current_extruder", new_filament_id); + this->placeholder_parser().set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(new_filament_id)); + this->placeholder_parser().set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(new_filament_id)); std::string gcode; // Append the filament start G-code. @@ -7146,6 +7154,9 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo this->placeholder_parser().set("current_extruder", new_filament_id); this->placeholder_parser().set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(new_filament_id)); this->placeholder_parser().set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(new_filament_id)); + this->placeholder_parser().set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(new_filament_id)); + this->placeholder_parser().set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(new_filament_id)); + // Append the filament start G-code. const std::string &filament_start_gcode = m_config.filament_start_gcode.get_at(new_filament_id); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index fbef24d60b..1da92475b4 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -880,7 +880,8 @@ static std::vector s_Preset_filament_options {/*"filament_colour", "filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", "activate_chamber_temp_control", "filament_long_retractions_when_cut","filament_retraction_distances_when_cut", "idle_temperature", //BBS filament change length while the extruder color - "filament_change_length","filament_prime_volume","filament_flush_volumetric_speed","filament_flush_temp" + "filament_change_length","filament_prime_volume","filament_flush_volumetric_speed","filament_flush_temp", + "long_retractions_when_ec", "retraction_distances_when_ec" }; static std::vector s_Preset_machine_limits_options { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 58c1f8a016..e8a614e051 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4461,6 +4461,20 @@ void PrintConfigDef::init_fff_params() def->max = 18; def->set_default_value(new ConfigOptionFloats {18}); + def = this->add("long_retractions_when_ec", coBools); + def->label = L("Long retraction when extruder change"); + def->mode = comAdvanced; + def->nullable = true; + def->set_default_value(new ConfigOptionBoolsNullable {false}); + + def = this->add("retraction_distances_when_ec", coFloats); + def->label = L("Retraction distance when extruder change"); + def->mode = comAdvanced; + def->nullable = true; + def->min = 0; + def->max = 10; + def->set_default_value(new ConfigOptionFloatsNullable{10}); + def = this->add("retract_length_toolchange", coFloats); def->label = L("Length"); //def->full_label = L("Retraction Length (Toolchange)"); @@ -7454,6 +7468,8 @@ std::set filament_options_with_variant = { "filament_retract_before_wipe", "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut", + "long_retractions_when_ec", + "retraction_distances_when_ec", "nozzle_temperature_initial_layer", "nozzle_temperature", "filament_flush_volumetric_speed", diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 24d8ba55d5..a5a1133f91 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1271,6 +1271,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionInt, enable_long_retraction_when_cut)) ((ConfigOptionFloats, retraction_distances_when_cut)) ((ConfigOptionBools, long_retractions_when_cut)) + ((ConfigOptionFloatsNullable, retraction_distances_when_ec)) + ((ConfigOptionBoolsNullable, long_retractions_when_ec)) ((ConfigOptionFloats, z_hop)) // BBS ((ConfigOptionEnumsGeneric, z_hop_types)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 93c8ef7e07..d8d5ac4221 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3852,6 +3852,8 @@ void TabFilament::build() optgroup = page->new_optgroup(L("Multi Filament")); optgroup->append_single_option_line("filament_flush_temp", "", 0); optgroup->append_single_option_line("filament_flush_volumetric_speed", "", 0); + optgroup->append_single_option_line("long_retractions_when_ec", "" , 0); + optgroup->append_single_option_line("retraction_distances_when_ec", "" , 0); optgroup = page->new_optgroup(L("Tool change parameters with single extruder MM printers"), "param_toolchange"); optgroup->append_single_option_line("filament_loading_speed_start", "semm"); @@ -4018,6 +4020,7 @@ void TabFilament::toggle_options() bool support_chamber_temp_control = this->m_preset_bundle->printers.get_edited_preset().config.opt_bool("support_chamber_temp_control"); toggle_line("chamber_temperatures", support_chamber_temp_control); } + if (m_active_page->title() == L("Setting Overrides")) update_filament_overrides_page(&cfg); @@ -4027,6 +4030,9 @@ void TabFilament::toggle_options() "filament_unloading_speed_start", "filament_unloading_speed", "filament_toolchange_delay", "filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed"}) toggle_option(el, !is_BBL_printer); + + const int extruder_idx = 0; // m_variant_combo->GetSelection(); // TODO: Orca hack + toggle_line("retraction_distances_when_ec", m_config->opt_bool("long_retractions_when_ec", extruder_idx), 256 + extruder_idx); } }