diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 9926a03394..48dd2b48b5 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -979,8 +979,9 @@ std::vector ToolOrdering::get_recommended_filament_maps(const std::vectorfilament_colour.get_at(used_filaments[idx])); auto ams_filament_info = print->get_extruder_filament_info(); - std::vector> ams_colors; - for (auto& arr : ams_filament_info) { + std::vector> ams_colors(extruder_nums); + for (size_t i = 0; i < ams_filament_info.size(); ++i) { + auto& arr = ams_filament_info[i]; std::vectorcolors; for (auto& item : arr) colors.emplace_back(item.option("filament_colour")->get_at(0)); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9c4885fd2d..e852243abd 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2808,6 +2808,7 @@ struct Plater::priv return false; #endif } + std::vector> get_extruder_filament_info(); void update_print_volume_state(); void schedule_background_process(); // Update background processing thread from the current config and Model. @@ -5500,6 +5501,24 @@ void Plater::priv::schedule_background_process() this->view3D->get_canvas3d()->set_config(this->config); } +std::vector> Plater::priv::get_extruder_filament_info() +{ + std::vector> filament_infos; + DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) + return filament_infos; + + MachineObject *obj_ = dev->get_selected_machine(); + if (obj_ == nullptr) + return filament_infos; + + if (!obj_->is_multi_extruders()) + return filament_infos; + + filament_infos = wxGetApp().preset_bundle->get_extruder_filament_info(); + return filament_infos; +} + void Plater::priv::update_print_volume_state() { //BBS: use the plate's bounding box instead of the bed's @@ -5589,7 +5608,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool PartPlate* cur_plate = background_process.get_current_plate(); std::vector f_maps = cur_plate->get_filament_maps(); invalidated = background_process.apply(this->model, wxGetApp().preset_bundle->full_config(false, f_maps)); - background_process.fff_print()->set_extruder_filament_info(wxGetApp().preset_bundle->get_extruder_filament_info()); + background_process.fff_print()->set_extruder_filament_info(get_extruder_filament_info()); } else invalidated = background_process.apply(this->model, wxGetApp().preset_bundle->full_config(false));