mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-04-21 05:10:01 +08:00
ENH: refine check logic for filament mix printing
jira: NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I199462cee6284e13e58f829b7972dd3124bfc385
This commit is contained in:
parent
d66d18529a
commit
22834b2358
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0.3",
|
||||
"version": "1.0.0.4",
|
||||
"high_temp_filament": [
|
||||
"ABS",
|
||||
"ASA",
|
||||
@ -25,12 +25,12 @@
|
||||
"PLA-AERO",
|
||||
"PVA",
|
||||
"BVOH",
|
||||
"PCTG"
|
||||
"PCTG",
|
||||
"PETG",
|
||||
"PETG-CF"
|
||||
],
|
||||
"high_low_compatible_filament":[
|
||||
"HIPS",
|
||||
"PETG",
|
||||
"PETG-CF",
|
||||
"PE",
|
||||
"PP",
|
||||
"EVA",
|
||||
|
@ -991,22 +991,29 @@ static StringObjectException layered_print_cleareance_valid(const Print &print,
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Print::check_multi_filaments_compatibility(const std::vector<std::string>& filament_types)
|
||||
FilamentCompatibilityType Print::check_multi_filaments_compatibility(const std::vector<std::string>& filament_types)
|
||||
{
|
||||
bool has_high_temperature_filament = false;
|
||||
bool has_low_temperature_filament = false;
|
||||
bool has_mid_temperature_filament = false;
|
||||
|
||||
for (const auto& type : filament_types) {
|
||||
if (get_filament_temp_type(type) ==FilamentTempType::HighTemp)
|
||||
has_high_temperature_filament = true;
|
||||
else if (get_filament_temp_type(type) == FilamentTempType::LowTemp)
|
||||
has_low_temperature_filament = true;
|
||||
else if (get_filament_temp_type(type) == FilamentTempType::HighLowCompatible)
|
||||
has_mid_temperature_filament = true;
|
||||
}
|
||||
|
||||
if (has_high_temperature_filament && has_low_temperature_filament)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return FilamentCompatibilityType::HighLowMixed;
|
||||
else if (has_high_temperature_filament && has_mid_temperature_filament)
|
||||
return FilamentCompatibilityType::HighMidMixed;
|
||||
else if (has_low_temperature_filament && has_mid_temperature_filament)
|
||||
return FilamentCompatibilityType::LowMidMixed;
|
||||
else
|
||||
return FilamentCompatibilityType::Compatible;
|
||||
}
|
||||
|
||||
bool Print::is_filaments_compatible(const std::vector<int>& filament_types)
|
||||
@ -1050,21 +1057,38 @@ int Print::get_compatible_filament_type(const std::set<int>& filament_types)
|
||||
//BBS: this function is used to check whether multi filament can be printed
|
||||
StringObjectException Print::check_multi_filament_valid(const Print& print)
|
||||
{
|
||||
if (!print.need_check_multi_filaments_compatibility())
|
||||
return {std::string()};
|
||||
|
||||
auto print_config = print.config();
|
||||
std::vector<unsigned int> extruders = print.extruders();
|
||||
std::vector<std::string> filament_types;
|
||||
filament_types.reserve(extruders.size());
|
||||
|
||||
for (const auto& extruder_idx : extruders)
|
||||
filament_types.push_back(print_config.filament_type.get_at(extruder_idx));
|
||||
|
||||
if (!check_multi_filaments_compatibility(filament_types))
|
||||
return { L("Can not print multiple filaments which have large difference of temperature together. Otherwise, the extruder and nozzle may be blocked or damaged during printing") };
|
||||
auto compatibility = check_multi_filaments_compatibility(filament_types);
|
||||
bool enable_mix_printing = !print.need_check_multi_filaments_compatibility();
|
||||
|
||||
return {std::string()};
|
||||
StringObjectException ret;
|
||||
|
||||
if(compatibility == FilamentCompatibilityType::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;
|
||||
}
|
||||
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 == FilamentCompatibilityType::HighMidMixed) {
|
||||
ret.is_warning = true;
|
||||
ret.string =L("Printing high-temp and mid-temp filaments together may cause nozzle clogging or printer damage.");
|
||||
|
||||
}
|
||||
else if (compatibility == FilamentCompatibilityType::LowMidMixed) {
|
||||
ret.is_warning = true;
|
||||
ret.string = L("Printing mid-temp and low-temp filaments together may cause nozzle clogging or printer damage.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Precondition: Print::validate() requires the Print::apply() to be called its invocation.
|
||||
@ -1084,6 +1108,10 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
||||
if (!ret.string.empty())
|
||||
{
|
||||
ret.type = STRING_EXCEPT_FILAMENTS_DIFFERENT_TEMP;
|
||||
if (ret.is_warning && warning != nullptr) {
|
||||
*warning = ret;
|
||||
return {};
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -784,6 +784,14 @@ enum FilamentTempType {
|
||||
HighLowCompatible,
|
||||
Undefine
|
||||
};
|
||||
|
||||
enum FilamentCompatibilityType {
|
||||
Compatible,
|
||||
HighLowMixed,
|
||||
HighMidMixed,
|
||||
LowMidMixed
|
||||
};
|
||||
|
||||
// The complete print tray with possibly multiple objects.
|
||||
class Print : public PrintBaseWithState<PrintStep, psCount>
|
||||
{
|
||||
@ -980,7 +988,7 @@ public:
|
||||
Vec2d translate_to_print_space(const Point& point) const;
|
||||
static FilamentTempType get_filament_temp_type(const std::string& filament_type);
|
||||
static int get_hrc_by_nozzle_type(const NozzleType& type);
|
||||
static bool check_multi_filaments_compatibility(const std::vector<std::string>& filament_types);
|
||||
static FilamentCompatibilityType check_multi_filaments_compatibility(const std::vector<std::string>& filament_types);
|
||||
// similar to check_multi_filaments_compatibility, but the input is int, and may be negative (means unset)
|
||||
static bool is_filaments_compatible(const std::vector<int>& types);
|
||||
// get the compatible filament type of a multi-material object
|
||||
|
@ -33,6 +33,7 @@ struct StringObjectException
|
||||
ObjectBase const *object = nullptr;
|
||||
std::string opt_key;
|
||||
StringExceptionType type; // warning type for tips
|
||||
bool is_warning = false;
|
||||
std::vector<std::string> params; // warning params for tips
|
||||
};
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ bool CalibrationPresetPage::is_filaments_compatiable(const std::map<int, Preset*
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Print::check_multi_filaments_compatibility(filament_types)) {
|
||||
if (Print::check_multi_filaments_compatibility(filament_types) == FilamentCompatibilityType::HighLowMixed) {
|
||||
error_tips = _u8L("Can not print multiple filaments which have large difference of temperature together. Otherwise, the extruder and nozzle may be blocked or damaged during printing");
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user