diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 46e57bd20..85a39d8fa 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1412,7 +1412,7 @@ void PresetBundle::set_num_filaments(unsigned int n, std::string new_color) update_multi_material_filament_presets(); } -unsigned int PresetBundle::sync_ams_list() +unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns) { std::vector filament_presets; std::vector filament_colors; @@ -1422,7 +1422,16 @@ unsigned int PresetBundle::sync_ams_list() auto iter = std::find_if(filaments.begin(), filaments.end(), [&filament_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == filament_id; }); if (iter == filaments.end()) { BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id; - continue; + auto filament_type = "Generic " + ams.opt_string("filament_type", 0u); + iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) { return f.is_compatible && f.is_system + && boost::algorithm::starts_with(f.name, filament_type); + }); + if (iter == filaments.end()) + iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) { return f.is_compatible && f.is_system; }); + if (iter == filaments.end()) + continue; + ++unknowns; + filament_id = iter->filament_id; } filament_presets.push_back(iter->name); filament_colors.push_back(filament_color); diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 1f2a07351..6cfb7b0e2 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -83,7 +83,7 @@ public: // BBS void set_num_filaments(unsigned int n, std::string new_col = ""); - unsigned int sync_ams_list(); + unsigned int sync_ams_list(unsigned int & unknowns); //BBS: check whether this is the only edited filament bool is_the_only_edited_filament(unsigned int filament_index); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1f9be3a01..247b6140e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1260,6 +1260,7 @@ void Sidebar::load_ams_list(std::map const &list) << boost::format(": ams %1% tray %2% id %3% color %4%") % ams.first % tray.first % tray.second->setting_id % tray.second->color; DynamicPrintConfig ams; ams.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id}); + ams.set_key_value("filament_type", new ConfigOptionStrings{tray.second->type}); ams.set_key_value("filament_colour", new ConfigOptionStrings{"#" + tray.second->color.substr(0, 6)}); filament_ams_list.emplace_back(std::move(ams)); } @@ -1283,7 +1284,8 @@ void Sidebar::sync_ams_list() _L("Sync filaments with AMS will drop all current selected filament presets and colors. Do you want to continue?"), _L("Sync filaments with AMS"), wxYES_NO); if (dlg.ShowModal() != wxID_YES) return; - auto n = wxGetApp().preset_bundle->sync_ams_list(); + unsigned int unknowns = 0; + auto n = wxGetApp().preset_bundle->sync_ams_list(unknowns); if (n == 0) { MessageDialog dlg(this, _L("There are no compatible filaments, and sync is not performed."), @@ -1291,6 +1293,12 @@ void Sidebar::sync_ams_list() dlg.ShowModal(); return; } + if (unknowns > 0) { + MessageDialog dlg(this, + _L("There are some unknown filaments mapped to generic preset. Please update Bambu Studio or restart Bambu Studio to check if there is an update to system presets."), + _L("Sync filaments with AMS"), wxOK); + dlg.ShowModal(); + } wxGetApp().plater()->on_filaments_change(n); for (auto &c : p->combos_filament) c->update();