ENH: add params for filament retract when extruder change

jira: STUDIO-11965

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Id175e9dbce419d43cf45d6116ed4fa4fd556f606
This commit is contained in:
xun.zhang 2025-05-07 11:39:16 +08:00 committed by lane.wei
parent ffe2653341
commit c796444171
6 changed files with 44 additions and 1 deletions

View File

@ -171,6 +171,9 @@
"nozzle_temperature_initial_layer": [ "nozzle_temperature_initial_layer": [
"200" "200"
], ],
"long_retractions_when_ec": [
"0"
],
"overhang_fan_speed": [ "overhang_fan_speed": [
"100" "100"
], ],
@ -183,6 +186,9 @@
"required_nozzle_HRC": [ "required_nozzle_HRC": [
"3" "3"
], ],
"retraction_distances_when_ec": [
"0"
],
"supertack_plate_temp": [ "supertack_plate_temp": [
"45" "45"
], ],

View File

@ -877,6 +877,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
gcodegen.placeholder_parser().set("current_extruder", new_filament_id); 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("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("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. // Process the start filament gcode.
std::string start_filament_gcode_str; std::string start_filament_gcode_str;
@ -2212,9 +2214,13 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
//set the key for compatibilty //set the key for compatibilty
m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(initial_extruder_id)); m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(initial_extruder_id));
m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(initial_extruder_id)); m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(initial_extruder_id));
m_placeholder_parser.set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(initial_extruder_id));
m_placeholder_parser.set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(initial_extruder_id));
m_placeholder_parser.set("retraction_distances_when_cut", new ConfigOptionFloatsNullable(m_config.retraction_distances_when_cut)); 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)); m_placeholder_parser.set("long_retractions_when_cut",new ConfigOptionBoolsNullable(m_config.long_retractions_when_cut));
m_placeholder_parser.set("retraction_distances_when_ec", new ConfigOptionFloatsNullable(m_config.retraction_distances_when_ec));
m_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. //Set variable for total layer count so it can be used in custom gcode.
m_placeholder_parser.set("total_layer_count", m_layer_count); m_placeholder_parser.set("total_layer_count", m_layer_count);
@ -6079,6 +6085,8 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
m_placeholder_parser.set("current_extruder", new_filament_id); m_placeholder_parser.set("current_extruder", new_filament_id);
m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(new_filament_id)); m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(new_filament_id));
m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(new_filament_id)); m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(new_filament_id));
m_placeholder_parser.set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(new_filament_id));
m_placeholder_parser.set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(new_filament_id));
std::string gcode; std::string gcode;
// Append the filament start G-code. // Append the filament start G-code.
@ -6316,6 +6324,9 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
m_placeholder_parser.set("current_extruder", new_filament_id); m_placeholder_parser.set("current_extruder", new_filament_id);
m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(new_filament_id)); m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(new_filament_id));
m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(new_filament_id)); m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(new_filament_id));
m_placeholder_parser.set("retraction_distance_when_ec", m_config.retraction_distances_when_ec.get_at(new_filament_id));
m_placeholder_parser.set("long_retraction_when_ec", m_config.long_retractions_when_ec.get_at(new_filament_id));
// Append the filament start G-code. // Append the filament start G-code.
const std::string &filament_start_gcode = m_config.filament_start_gcode.get_at(new_filament_id); const std::string &filament_start_gcode = m_config.filament_start_gcode.get_at(new_filament_id);

View File

@ -937,7 +937,8 @@ static std::vector<std::string> s_Preset_filament_options {/*"filament_colour",
"enable_pressure_advance", "pressure_advance", "chamber_temperatures","filament_notes", "enable_pressure_advance", "pressure_advance", "chamber_temperatures","filament_notes",
"filament_long_retractions_when_cut","filament_retraction_distances_when_cut","filament_shrink", "filament_long_retractions_when_cut","filament_retraction_distances_when_cut","filament_shrink",
//BBS filament change length while the extruder color //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<std::string> s_Preset_machine_limits_options { static std::vector<std::string> s_Preset_machine_limits_options {

View File

@ -3342,6 +3342,20 @@ void PrintConfigDef::init_fff_params()
def->nullable = true; def->nullable = true;
def->set_default_value(new ConfigOptionFloatsNullable {18}); def->set_default_value(new ConfigOptionFloatsNullable {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 = this->add("retract_length_toolchange", coFloats);
def->label = L("Length"); def->label = L("Length");
//def->full_label = L("Retraction Length (Toolchange)"); //def->full_label = L("Retraction Length (Toolchange)");
@ -5724,6 +5738,8 @@ std::set<std::string> filament_options_with_variant = {
"filament_retract_before_wipe", "filament_retract_before_wipe",
"filament_long_retractions_when_cut", "filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut", "filament_retraction_distances_when_cut",
"long_retractions_when_ec",
"retraction_distances_when_ec",
"nozzle_temperature_initial_layer", "nozzle_temperature_initial_layer",
"nozzle_temperature", "nozzle_temperature",
"filament_flush_volumetric_speed", "filament_flush_volumetric_speed",

View File

@ -1083,6 +1083,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionInt, enable_long_retraction_when_cut)) ((ConfigOptionInt, enable_long_retraction_when_cut))
((ConfigOptionFloatsNullable, retraction_distances_when_cut)) ((ConfigOptionFloatsNullable, retraction_distances_when_cut))
((ConfigOptionBoolsNullable, long_retractions_when_cut)) ((ConfigOptionBoolsNullable, long_retractions_when_cut))
((ConfigOptionFloatsNullable, retraction_distances_when_ec))
((ConfigOptionBoolsNullable, long_retractions_when_ec))
((ConfigOptionFloatsNullable, z_hop)) ((ConfigOptionFloatsNullable, z_hop))
// BBS // BBS
((ConfigOptionEnumsGenericNullable,z_hop_types)) ((ConfigOptionEnumsGenericNullable,z_hop_types))

View File

@ -3513,6 +3513,8 @@ void TabFilament::build()
optgroup = page->new_optgroup(L("Multi Filament")); optgroup = page->new_optgroup(L("Multi Filament"));
optgroup->append_single_option_line("filament_flush_temp", "", 0); optgroup->append_single_option_line("filament_flush_temp", "", 0);
optgroup->append_single_option_line("filament_flush_volumetric_speed", "", 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);
//BBS //BBS
#if 0 #if 0
//page = add_options_page(L("Dependencies"), "advanced"); //page = add_options_page(L("Dependencies"), "advanced");
@ -3619,6 +3621,11 @@ void TabFilament::toggle_options()
toggle_line(el, is_BBL_printer); toggle_line(el, is_BBL_printer);
} }
if(m_active_page->title() == "Multi Filament"){
const int extruder_idx = m_variant_combo->GetSelection();
toggle_line("retraction_distances_when_ec", m_config->opt_bool_nullable("long_retractions_when_ec", extruder_idx), 256 + extruder_idx);
}
if (m_active_page->title() == "Setting Overrides") if (m_active_page->title() == "Setting Overrides")
update_filament_overrides_page(); update_filament_overrides_page();
} }