diff --git a/resources/printers/filaments_blacklist.json b/resources/printers/filaments_blacklist.json index 82a7fdae3..636c628fc 100644 --- a/resources/printers/filaments_blacklist.json +++ b/resources/printers/filaments_blacklist.json @@ -3,74 +3,22 @@ ], "blacklist": [ { - "vendor": "Third Party", "type": "TPU", "action": "prohibition", "description": "TPU: not supported" }, { - "vendor": "Bambu Lab", - "type": "TPU", - "action": "prohibition", - "description": "TPU: not supported" - }, - { - "vendor": "Third Party", "type": "PVA", "action": "warning", "description": "PVA: flexible" }, { - "vendor": "Bambu Lab", - "type": "PVA", - "action": "warning", - "description": "PVA: flexible" - }, - { - "vendor": "Third Party", - "type": "PLA-CF", + "type_suffix": "CF", "action": "warning", "description": "CF/GF: hard and brittle" }, { - "vendor": "Third Party", - "type": "PETG-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PA-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PAHT-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PET-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PA6-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PPS-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Third Party", - "type": "PPA-CF", + "type_suffix": "GF", "action": "warning", "description": "CF/GF: hard and brittle" }, @@ -81,30 +29,6 @@ "model_id":["N1","N2S"], "action": "warning", "description": "PLA-Glow" - }, - { - "vendor": "Bambu Lab", - "type": "PET-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Bambu Lab", - "type": "PA6-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Bambu Lab", - "type": "PPS-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" - }, - { - "vendor": "Bambu Lab", - "type": "PPA-CF", - "action": "warning", - "description": "CF/GF: hard and brittle" } ] } diff --git a/resources/printers/version.txt b/resources/printers/version.txt index e9514d96e..3dbc8d48e 100644 --- a/resources/printers/version.txt +++ b/resources/printers/version.txt @@ -1 +1 @@ -02.00.00.22 \ No newline at end of file +02.00.00.24 \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 0444e3992..b389ec7cb 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -7948,89 +7948,53 @@ void check_filaments_for_ams_slot(std::string model_id, in_blacklist = false; - if (DeviceManager::filaments_blacklist.contains("blacklist")) - { - for (auto prohibited_filament : DeviceManager::filaments_blacklist["blacklist"]) - { + std::transform(tag_vendor.begin(), tag_vendor.end(), tag_vendor.begin(), ::tolower); + std::transform(tag_type.begin(), tag_type.end(), tag_type.begin(), ::tolower); + std::transform(tag_name.begin(), tag_name.end(), tag_name.begin(), ::tolower); + if (DeviceManager::filaments_blacklist.contains("blacklist")) { + for (auto filament_item : DeviceManager::filaments_blacklist["blacklist"]) { - std::string vendor; - std::string type; - std::string action; - std::string description; - std::string name = "undefine"; - std::vector model_ids; + std::string vendor = filament_item.contains("vendor") ? filament_item["vendor"].get() : ""; + std::string type = filament_item.contains("type") ? filament_item["type"].get() : ""; + std::string type_suffix = filament_item.contains("type_suffix") ? filament_item["type_suffix"].get() : ""; + std::string name = filament_item.contains("name") ? filament_item["name"].get() : ""; + std::vector model_ids = filament_item.contains("model_id") ? filament_item["model_id"].get>() : std::vector(); + std::string action = filament_item.contains("action") ? filament_item["action"].get() : ""; + std::string description = filament_item.contains("description") ? filament_item["description"].get() : ""; - if (prohibited_filament.contains("vendor") && - prohibited_filament.contains("type") && - prohibited_filament.contains("action") && - prohibited_filament.contains("description")) - { - vendor = prohibited_filament["vendor"].get(); - type = prohibited_filament["type"].get(); - action = prohibited_filament["action"].get(); - description = prohibited_filament["description"].get(); - } - else - { - return; - } - - if (prohibited_filament.contains("name")) - { - name = prohibited_filament["name"].get(); - } - - if (prohibited_filament.contains("model_id")) - { - for (auto res : prohibited_filament["model_id"]) - model_ids.emplace_back(res.get()); - } + // check model id + if (!model_ids.empty() && std::find(model_ids.begin(), model_ids.end(), model_id) == model_ids.end()) { continue;} + // check vendor std::transform(vendor.begin(), vendor.end(), vendor.begin(), ::tolower); - std::transform(tag_vendor.begin(), tag_vendor.end(), tag_vendor.begin(), ::tolower); - std::transform(tag_type.begin(), tag_type.end(), tag_type.begin(), ::tolower); + if (!vendor.empty()) { + if ((vendor == "bambu lab" && (tag_vendor == vendor)) || + (vendor == "third party" && (tag_vendor != "bambu lab"))){ + // Do nothing + } else { + continue; + } + } + + // check type std::transform(type.begin(), type.end(), type.begin(), ::tolower); + if (!type.empty() && (type != tag_type)) { continue; } - - bool mactch_printer = false; - auto it = std::find(model_ids.begin(), model_ids.end(), model_id); - if (it != model_ids.end()) { mactch_printer = true; } - - // third party - if (vendor == "third party") - { - if ("bambu lab" != tag_vendor && tag_type == type) - { - if (name == "undefine" || (tag_name.find(name) != std::string::npos)) - { - - if (model_ids.empty() || mactch_printer) - { - in_blacklist = true; - ac = action; - info = blacklist_prompt[description].ToStdString(); - return; - } - } - } + // check type suffix + std::transform(type_suffix.begin(), type_suffix.end(), type_suffix.begin(), ::tolower); + if (!type_suffix.empty()) { + if (tag_type.length() < type_suffix.length()) { continue; } + if ((tag_type.substr(tag_type.length() - type_suffix.length()) != type_suffix)) { continue; } } - else - { - if (vendor == tag_vendor && tag_type == type) - { - if (name == "undefine" || (tag_name.find(name) != std::string::npos)) - { - if (model_ids.empty() || mactch_printer) - { - in_blacklist = true; - ac = action; - info = blacklist_prompt[description].ToStdString(); - return; - } - } - } - } + // check name + std::transform(name.begin(), name.end(), name.begin(), ::tolower); + if (!name.empty() && (name != tag_name)) { continue;} + + in_blacklist = true; + ac = action; + info = blacklist_prompt[description].ToStdString(); + return; } } }