diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index ef2033eefd..ac0bfe2182 100644 --- a/src/libslic3r/ProjectTask.hpp +++ b/src/libslic3r/ProjectTask.hpp @@ -53,6 +53,20 @@ struct FilamentInfo /*for new ams mapping*/ std::string ams_id; std::string slot_id; + +public: + int get_amd_id() const + { + if (ams_id.empty()) { return -1; }; + + try + { + return stoi(ams_id); + } + catch (...) {}; + + return -1; + }; }; class BBLSliceInfo { diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 965fa67761..38143c62bd 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1199,7 +1199,7 @@ bool MachineObject::need_SD_card() const int MachineObject::get_extruder_id_by_ams_id(const std::string &ams_id) { - if (ams_id.empty()) + if (ams_id.empty() || (ams_id == "-1")) return 0; auto it = amsList.find(ams_id); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index ece68f5009..a56ba0bc4b 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -2108,7 +2108,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) //check blacklist for (auto i = 0; i < m_ams_mapping_result.size(); i++) { - const auto& ams_id = m_ams_mapping_result[i].ams_id; + const auto& ams_id = m_ams_mapping_result[i].get_amd_id(); auto tid = m_ams_mapping_result[i].tray_id; std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); @@ -2124,7 +2124,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) std::string action; std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, stoi(ams_id), in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, ams_id, in_blacklist, action, info); if (in_blacklist && action == "warning") { wxString prohibited_error = wxString::FromUTF8(info); @@ -2175,7 +2175,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) for (auto i = 0; i < m_ams_mapping_result.size(); i++) { - const auto& ams_id = m_ams_mapping_result[i].ams_id; + const auto& ams_id = m_ams_mapping_result[i].get_amd_id(); auto tid = m_ams_mapping_result[i].tray_id; std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); @@ -2190,7 +2190,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) bool in_blacklist = false; std::string action; std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, stoi(ams_id), in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, ams_id, in_blacklist, action, info); if (in_blacklist && action == "prohibition") { has_prohibited_filament = true;