From cdf66984dd182fa140e7a3b34a3b1a9685632d50 Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Sun, 27 Apr 2025 21:26:07 +0800 Subject: [PATCH] ENH: add flush params for multi filament jira: STUDIO-11965 Signed-off-by: xun.zhang Change-Id: I2245f22a03c65b570bc60a2792daf4c1683f1ebd (cherry picked from commit ffe2653341bffd5aee42436e236d45e0b87b56aa) --- .../BBL/filament/fdm_filament_common.json | 6 +++++ src/libslic3r/GCode.cpp | 25 +++++++++++++++++++ src/libslic3r/Preset.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 23 +++++++++++++++-- src/libslic3r/PrintConfig.hpp | 2 ++ src/slic3r/GUI/Tab.cpp | 5 +++- 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/resources/profiles/BBL/filament/fdm_filament_common.json b/resources/profiles/BBL/filament/fdm_filament_common.json index 3072f73b8d..517b5691e7 100644 --- a/resources/profiles/BBL/filament/fdm_filament_common.json +++ b/resources/profiles/BBL/filament/fdm_filament_common.json @@ -57,6 +57,12 @@ "filament_flow_ratio": [ "1" ], + "filament_flush_temp": [ + "0" + ], + "filament_flush_volumetric_speed": [ + "0" + ], "filament_is_support": [ "0" ], diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index d673b5b6b5..cd3be75f1d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -819,6 +819,18 @@ static std::vector get_path_of_change_filament(const Print& print) config.set_key_value("travel_point_3_x", new ConfigOptionFloat(float(travel_point_3.x()))); config.set_key_value("travel_point_3_y", new ConfigOptionFloat(float(travel_point_3.y()))); + auto flush_v_speed = m_print_config->filament_flush_volumetric_speed.values; + auto flush_temps = m_print_config->filament_flush_temp.values; + for (size_t idx = 0; idx < flush_v_speed.size(); ++idx) { + if (flush_v_speed[idx] == 0) + flush_v_speed[idx] = m_print_config->filament_max_volumetric_speed.get_at(idx); + } + for (size_t idx = 0; idx < flush_temps.size(); ++idx) { + if (flush_temps[idx] == 0) + flush_temps[idx] = m_print_config->nozzle_temperature_range_high.get_at(idx); + } + config.set_key_value("flush_volumetric_speeds", new ConfigOptionFloats(flush_v_speed)); + config.set_key_value("flush_temperatures", new ConfigOptionInts(flush_temps)); config.set_key_value("flush_length", new ConfigOptionFloat(purge_length)); config.set_key_value("wipe_avoid_perimeter", new ConfigOptionBool(is_used_travel_avoid_perimeter)); config.set_key_value("wipe_avoid_pos_x", new ConfigOptionFloat(wipe_avoid_pos_x)); @@ -2499,6 +2511,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato 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)); + //Set variable for total layer count so it can be used in custom gcode. this->placeholder_parser().set("total_layer_count", m_layer_count); // Useful for sequential prints. @@ -7047,6 +7060,18 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo dyn_config.set_key_value("wipe_avoid_perimeter", new ConfigOptionBool(false)); dyn_config.set_key_value("wipe_avoid_pos_x", new ConfigOptionFloat(wipe_avoid_pos_x)); + auto flush_v_speed = m_print->config().filament_flush_volumetric_speed.values; + auto flush_temps =m_print->config().filament_flush_temp.values; + for (size_t idx = 0; idx < flush_v_speed.size(); ++idx) { + if (flush_v_speed[idx] == 0) + flush_v_speed[idx] = m_print->config().filament_max_volumetric_speed.get_at(idx); + } + for (size_t idx = 0; idx < flush_temps.size(); ++idx) { + if (flush_temps[idx] == 0) + flush_temps[idx] = m_print->config().nozzle_temperature_range_high.get_at(idx); + } + dyn_config.set_key_value("flush_volumetric_speeds", new ConfigOptionFloats(flush_v_speed)); + dyn_config.set_key_value("flush_temperatures", new ConfigOptionInts(flush_temps)); dyn_config.set_key_value("flush_length", new ConfigOptionFloat(wipe_length)); int flush_count = std::min(g_max_flush_count, (int)std::round(wipe_volume / g_purge_volume_one_time)); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index d49d5fa35e..fbef24d60b 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -880,7 +880,7 @@ 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_change_length","filament_prime_volume","filament_flush_volumetric_speed","filament_flush_temp" }; static std::vector s_Preset_machine_limits_options { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 55904e5bc9..58c1f8a016 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2176,6 +2176,24 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionEnum(fmmAutoForFlush)); + def = this->add("filament_flush_temp", coInts); + def->label = L("Flush temperature"); + def->tooltip = L("temperature when flushing filament"); + def->mode = comAdvanced; + def->nullable = true; + def->min = 0; + def->max = max_temp; + def->set_default_value(new ConfigOptionIntsNullable{0}); + + def = this->add("filament_flush_volumetric_speed", coFloats); + def->label = L("Flush volumetric speed"); + def->tooltip = L("Volumetric speed when flushing filament"); + def->mode = comAdvanced; + def->nullable = true; + def->min = 0; + def->max = 200; + def->set_default_value(new ConfigOptionFloatsNullable{ 0 }); + def = this->add("filament_max_volumetric_speed", coFloats); def->label = L("Max volumetric speed"); def->tooltip = L("This setting stands for how much volume of filament can be melted and extruded per second. " @@ -7437,8 +7455,9 @@ std::set filament_options_with_variant = { "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut", "nozzle_temperature_initial_layer", - "nozzle_temperature" - + "nozzle_temperature", + "filament_flush_volumetric_speed", + "filament_flush_temp" }; // Parameters that are the same as the number of extruders diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index fb600f9b8b..24d8ba55d5 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1246,6 +1246,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionStrings, filament_extruder_variant)) ((ConfigOptionEnum, bed_temperature_formula)) ((ConfigOptionInts, physical_extruder_map)) + ((ConfigOptionFloatsNullable, filament_flush_volumetric_speed)) + ((ConfigOptionIntsNullable, filament_flush_temp)) // BBS ((ConfigOptionBool, scan_first_layer)) ((ConfigOptionPoints, thumbnail_size)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6a57604b84..93c8ef7e07 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3848,6 +3848,10 @@ void TabFilament::build() page = add_options_page(L("Multimaterial"), "custom-gcode_multi_material"); // ORCA: icon only visible on placeholders optgroup = page->new_optgroup(L("Wipe tower parameters"), "param_tower"); optgroup->append_single_option_line("filament_minimal_purge_on_wipe_tower"); + + 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 = page->new_optgroup(L("Tool change parameters with single extruder MM printers"), "param_toolchange"); optgroup->append_single_option_line("filament_loading_speed_start", "semm"); @@ -4758,7 +4762,6 @@ if (is_marlin_flavor) // do not display this params now optgroup->append_single_option_line("long_retractions_when_cut", "", extruder_idx); optgroup->append_single_option_line("retraction_distances_when_cut", "", extruder_idx); - #if 0 //optgroup = page->new_optgroup(L("Preview"), -1, true);