From 641577c83560e8515515301082e2d966d0cb71b9 Mon Sep 17 00:00:00 2001 From: "songwei.li" Date: Tue, 29 Jul 2025 09:24:30 +0800 Subject: [PATCH] FIX: error of the mixed material printing is lost when by-object In print.cpp, logic was added to skip checking for mixed prints when using the byobject mode. This prevented false positives for single-filament objects, but it also failed to detect mixed prints. This detection has been restored, but separate logic for byobject mode has been added to the detection function: StringObjectException Print::check_multi_filament_valid(const Print& print). This will only prompt a warning when a single object contains high- and low-temperature filaments. jira: STUDIO-13667 Change-Id: I37622e49b76581ea4a2d78c97ebcd655bb7199e6 (cherry picked from commit 7128758056f1fe11bdd953e7f3d91284b15535a9) --- src/libslic3r/Print.cpp | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 8f3cb8d518..93a4603380 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1097,6 +1097,53 @@ int Print::get_compatible_filament_type(const std::set& filament_types) StringObjectException Print::check_multi_filament_valid(const Print& print) { auto print_config = print.config(); + if(print_config.print_sequence == PrintSequence::ByObject) {// use ByObject valid under ByObject print sequence + std::set Compatibility_each_obj; + bool enable_mix_printing = !print.need_check_multi_filaments_compatibility(); + + for (const auto &objectID_t : print.print_object_ids()) { + std::set obj_used_extruder_ids; + auto print_object = print.get_object(objectID_t);// current object + if (print_object){ + auto object_extruders_t = print_object->object_extruders(); // object used extruder + for (int extruder : object_extruders_t) { + assert(extruder > 0); + obj_used_extruder_ids.insert(extruder); + } + } + + if (print_object->has_support_material()) { // extruder used by supports + auto num_extruders = (unsigned int) print_config.filament_diameter.size(); + assert(print_object->config().support_filament >= 0); + if (print_object->config().support_filament >= 1 && (unsigned int)print_object->config().support_filament < num_extruders + 1) + obj_used_extruder_ids.insert((unsigned int) print_object->config().support_filament - 1);//0-based extruder id + assert(print_object->config().support_interface_filament >= 0); + if (print_object->config().support_interface_filament >= 1 && (unsigned int)print_object->config().support_interface_filament < num_extruders + 1) + obj_used_extruder_ids.insert((unsigned int) print_object->config().support_interface_filament - 1); + } + std::vector filament_types; + filament_types.reserve(obj_used_extruder_ids.size()); + for (const auto &extruder_idx : obj_used_extruder_ids) filament_types.push_back(print_config.filament_type.get_at(extruder_idx)); + + auto compatibility = check_multi_filaments_compatibility(filament_types);// check for each object + Compatibility_each_obj.insert(compatibility); + } + StringObjectException ret; + std::string hypertext = "filament_mix_print"; + if (Compatibility_each_obj.count(FilamentCompatibilityType::HighLowMixed)){// at least one object has HighLowMixed + if (enable_mix_printing) { + ret.string = L("Printing high-temp and low-temp filaments together may cause nozzle clogging or printer damage."); + ret.is_warning = true; + // ret.hypetext = hypertext; + } else + ret.string = L("Printing high-temp and low-temp filaments together may cause nozzle clogging or printer damage. If you still want to print, you can enable the option in Preferences."); + }else if (Compatibility_each_obj.count(FilamentCompatibilityType::LowMidMixed) || Compatibility_each_obj.count(FilamentCompatibilityType::HighMidMixed)){// at least one object has other Mixed + ret.is_warning = true; + // ret.hypetext = hypertext; + ret.string = L("Printing different-temp filaments together may cause nozzle clogging or printer damage."); + } + return ret; + } std::vector extruders = print.extruders(); std::vector filament_types; filament_types.reserve(extruders.size()); @@ -1147,7 +1194,7 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons* if (extruders.empty()) return { L("No extrusions under current settings.") }; - if (nozzles < 2 && extruders.size() > 1 && m_config.print_sequence != PrintSequence::ByObject) { + if (nozzles < 2 && extruders.size() > 1) { auto ret = check_multi_filament_valid(*this); if (!ret.string.empty()) {