From c64270f506a4d004f66aef3ff31760f793eca489 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 1 Apr 2025 18:44:30 +0800 Subject: [PATCH] ENH: add printable filament types for extruder jira: none Change-Id: Ie6ada223bc11a53b975c8c20b4a41e7cdc2d524c --- .../BBL/machine/fdm_bbl_3dp_002_common.json | 4 ++ src/BambuStudio.cpp | 20 ++++++++ src/libslic3r/Preset.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 6 +++ src/libslic3r/PrintConfig.hpp | 1 + src/slic3r/GUI/DeviceManager.cpp | 48 +++++++++++++------ src/slic3r/GUI/PartPlate.cpp | 38 +++++++++++---- 7 files changed, 94 insertions(+), 25 deletions(-) diff --git a/resources/profiles/BBL/machine/fdm_bbl_3dp_002_common.json b/resources/profiles/BBL/machine/fdm_bbl_3dp_002_common.json index a86aff036..54b4789ca 100644 --- a/resources/profiles/BBL/machine/fdm_bbl_3dp_002_common.json +++ b/resources/profiles/BBL/machine/fdm_bbl_3dp_002_common.json @@ -49,6 +49,10 @@ "320", "325" ], + "printable_filament_types" : [ + "", + "" + ], "unprintable_filament_types" : [ "", "" diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 647703e89..a37c3403a 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -5872,6 +5872,16 @@ int CLI::run(int argc, char **argv) unprintable_filament_type_list[index] = unprintable_list; } + std::vector & printable_filament_types = m_print_config.option("printable_filament_types", true)->values; + std::vector> printable_filament_type_list; + printable_filament_type_list.resize(new_extruder_count); + for (int index = 0; index < new_extruder_count; index++) { + std::vector printable_list; + if (printable_filament_types.size() > index) + printable_list = split_string(printable_filament_types[index], ','); + printable_filament_type_list[index] = printable_list; + } + for (int index = 0; index < filament_maps.size(); index++) { int filament_extruder = filament_maps[index]; @@ -5887,6 +5897,7 @@ int CLI::run(int argc, char **argv) if (plate_filaments[f_index] <= filament_count) { int filament_extruder = filament_maps[plate_filaments[f_index] - 1]; std::vector& unprintable_list = unprintable_filament_type_list[filament_extruder-1]; + std::vector& printable_list = printable_filament_type_list[filament_extruder-1]; std::string filament_type; m_print_config.get_filament_type(filament_type, plate_filaments[f_index]-1); if (unprintable_list.size() > 0) @@ -5898,6 +5909,15 @@ int CLI::run(int argc, char **argv) flush_and_exit(CLI_FILAMENTS_NOT_SUPPORTED_BY_EXTRUDER); } } + if (printable_list.size() > 0) { + auto iter = std::find(printable_list.begin(), printable_list.end(), filament_type); + if (iter == printable_list.end()) { + BOOST_LOG_TRIVIAL(error) << boost::format("plate %1% : filament %2% can not be printed on extruder %3%, under manual mode for multi extruder printer, not in printable filament list") % (index + 1) % filament_type % filament_extruder; + record_exit_reson(outfile_dir, CLI_FILAMENTS_NOT_SUPPORTED_BY_EXTRUDER, index + 1, + cli_errors[CLI_FILAMENTS_NOT_SUPPORTED_BY_EXTRUDER], sliced_info); + flush_and_exit(CLI_FILAMENTS_NOT_SUPPORTED_BY_EXTRUDER); + } + } } } } diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index ee028d811..407bb9e15 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -953,7 +953,7 @@ static std::vector s_Preset_printer_options { "single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode","printing_by_object_gcode","before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "printer_model", "printer_variant", "printer_extruder_id", "printer_extruder_variant", "extruder_variant_list", "default_nozzle_volume_type", "printable_height", "extruder_printable_height", "extruder_clearance_dist_to_rod", "extruder_clearance_max_radius","extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", - "nozzle_height", "unprintable_filament_types", "master_extruder_id", + "nozzle_height", "printable_filament_types", "unprintable_filament_types","master_extruder_id", "default_print_profile", "inherits", "silent_mode", // BBS diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 942d9b1e8..23671a4b8 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -588,6 +588,12 @@ void PrintConfigDef::init_common_params() def->mode = comDevelop; def->set_default_value(new ConfigOptionStrings{""}); + def = this->add("printable_filament_types", coStrings); + def->label = L("Printable filament type"); + def->tooltip = L("Printable filament type"); + def->mode = comDevelop; + def->set_default_value(new ConfigOptionStrings{""}); + // Options used by physical printers def = this->add("preset_names", coStrings); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 3d1e89925..8da9f33aa 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1135,6 +1135,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionPoints, head_wrap_detect_zone)) // BBS ((ConfigOptionStrings, unprintable_filament_types)) + ((ConfigOptionStrings, printable_filament_types)) ((ConfigOptionString, bed_custom_texture)) ((ConfigOptionString, bed_custom_model)) ((ConfigOptionEnum, curr_bed_type)) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 52d0f8542..29b6e71df 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -7804,25 +7804,43 @@ bool DeviceManager::check_filaments_printable(const std::string &tag_vendor, con if (!printer_preset) return true; - ConfigOptionStrings *unprintable_filament_types_op = dynamic_cast(printer_preset->config.option("unprintable_filament_types")); - if (!unprintable_filament_types_op) - return true; - ConfigOptionInts *physical_extruder_map_op = dynamic_cast(printer_preset->config.option("physical_extruder_map")); if (!physical_extruder_map_op) return true; - std::vector physical_extruder_maps = physical_extruder_map_op->values; - for (size_t idx = 0; idx < unprintable_filament_types_op->values.size(); ++idx) { - if (physical_extruder_maps[idx] == obj->get_extruder_id_by_ams_id(std::to_string(ams_id))) { - std::vector filament_types = split_string(unprintable_filament_types_op->values.at(idx), ','); - auto iter = std::find(filament_types.begin(), filament_types.end(), tag_type); - if (iter != filament_types.end()) { - wxString extruder_name = idx == 0 ? _L("left") : _L("right"); - ac = "prohibition"; - info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data(); - in_blacklist = true; - return false; + + ConfigOptionStrings *unprintable_filament_types_op = dynamic_cast(printer_preset->config.option("unprintable_filament_types")); + if (unprintable_filament_types_op) { + for (size_t idx = 0; idx < unprintable_filament_types_op->values.size(); ++idx) { + if (physical_extruder_maps[idx] == obj->get_extruder_id_by_ams_id(std::to_string(ams_id))) { + std::vector filament_types = split_string(unprintable_filament_types_op->values.at(idx), ','); + auto iter = std::find(filament_types.begin(), filament_types.end(), tag_type); + if (iter != filament_types.end()) { + wxString extruder_name = idx == 0 ? _L("left") : _L("right"); + ac = "prohibition"; + info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data(); + in_blacklist = true; + return false; + } + } + } + } + + ConfigOptionStrings *printable_filament_types_op = dynamic_cast(printer_preset->config.option("printable_filament_types")); + if (printable_filament_types_op) { + for (size_t idx = 0; idx < printable_filament_types_op->values.size(); ++idx) { + if (physical_extruder_maps[idx] == obj->get_extruder_id_by_ams_id(std::to_string(ams_id))) { + std::vector filament_types = split_string(printable_filament_types_op->values.at(idx), ','); + if (!filament_types.empty()) { + auto iter = std::find(filament_types.begin(), filament_types.end(), tag_type); + if (iter == filament_types.end()) { + wxString extruder_name = idx == 0 ? _L("left") : _L("right"); + ac = "prohibition"; + info = (wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name)).ToUTF8().data(); + in_blacklist = true; + return false; + } + } } } } diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 2c9beea49..b315cd29c 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1344,15 +1344,35 @@ bool PartPlate::check_filament_printable(const DynamicPrintConfig &config, wxStr std::vector filament_map = get_real_filament_maps(config); int extruder_idx = filament_map[filament_id] - 1; std::string filament_types_str; - auto unprintable_filament_types = config.option("unprintable_filament_types")->values; - if (extruder_idx < unprintable_filament_types.size()) - filament_types_str = unprintable_filament_types.at(extruder_idx); - std::vector filament_types = split_string(filament_types_str, ','); - auto iter = std::find(filament_types.begin(), filament_types.end(), filament_type); - if (iter != filament_types.end()) { - wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right"); - error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type); - return false; + auto unprintable_filament_opt = config.option("unprintable_filament_types"); + if (unprintable_filament_opt) { + auto unprintable_filament_types = unprintable_filament_opt->values; + if (extruder_idx < unprintable_filament_types.size()) + filament_types_str = unprintable_filament_types.at(extruder_idx); + std::vector filament_types = split_string(filament_types_str, ','); + auto iter = std::find(filament_types.begin(), filament_types.end(), filament_type); + if (iter != filament_types.end()) { + wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right"); + error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type); + return false; + } + } + + filament_types_str.clear(); + auto printable_filament_opt = config.option("printable_filament_types"); + if (printable_filament_opt) { + auto printable_filament_types = printable_filament_opt->values; + if (extruder_idx < printable_filament_types.size()) + filament_types_str = printable_filament_types.at(extruder_idx); + std::vector filament_types = split_string(filament_types_str, ','); + if (!filament_types.empty()) { + auto iter = std::find(filament_types.begin(), filament_types.end(), filament_type); + if (iter == filament_types.end()) { + wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right"); + error_message = wxString::Format(_L("The %s nozzle can not print %s."), extruder_name, filament_type); + return false; + } + } } } }