From ffe2653341bffd5aee42436e236d45e0b87b56aa 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 --- .../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 | 6 ++++- 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/resources/profiles/BBL/filament/fdm_filament_common.json b/resources/profiles/BBL/filament/fdm_filament_common.json index 99b3e3f32..d81f76b47 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 c5bacd66d..6f9b3bc15 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -765,6 +765,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)); @@ -2203,6 +2215,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_placeholder_parser.set("retraction_distances_when_cut", new ConfigOptionFloatsNullable(m_config.retraction_distances_when_cut)); m_placeholder_parser.set("long_retractions_when_cut",new ConfigOptionBoolsNullable(m_config.long_retractions_when_cut)); + //Set variable for total layer count so it can be used in custom gcode. m_placeholder_parser.set("total_layer_count", m_layer_count); // Useful for sequential prints. @@ -6217,6 +6230,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 23aa7bd0e..da915ef5d 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -937,7 +937,7 @@ static std::vector s_Preset_filament_options {/*"filament_colour", "enable_pressure_advance", "pressure_advance", "chamber_temperatures","filament_notes", "filament_long_retractions_when_cut","filament_retraction_distances_when_cut","filament_shrink", //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 687a10b7a..1a6ba6f12 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1733,6 +1733,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. " @@ -5707,8 +5725,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 b84b902d9..5a6706d40 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1062,6 +1062,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloatsNullable, hotend_cooling_rate)) ((ConfigOptionFloatsNullable, hotend_heating_rate)) ((ConfigOptionFloats, filament_minimal_purge_on_wipe_tower)) + ((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 bbf0e27b7..12e23afb0 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3508,6 +3508,11 @@ void TabFilament::build() optgroup->append_single_option_line(option); optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { validate_custom_note_cb(this, optgroup, opt_key, value); }; + + page = add_options_page(L("Multi Filament"), "advanced"); + 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); //BBS #if 0 //page = add_options_page(L("Dependencies"), "advanced"); @@ -4274,7 +4279,6 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) // 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);