diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index eda894d4a3..80ea287564 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2594,18 +2594,25 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato max_chamber_temp = std::max(max_chamber_temp, m_config.chamber_temperature.get_at(extruder.id())); } { - int curr_bed_type = m_config.curr_bed_type.getInt(); + BedType curr_bed_type = m_config.curr_bed_type; std::string first_layer_bed_temp_str; const ConfigOptionInts* first_bed_temp_opt = m_config.option(get_bed_temp_1st_layer_key((BedType)curr_bed_type)); const ConfigOptionInts* bed_temp_opt = m_config.option(get_bed_temp_key((BedType)curr_bed_type)); + int target_bed_temp=0; + if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp) + target_bed_temp = get_highest_bed_temperature(true, print); + else + target_bed_temp = get_bed_temperature(initial_extruder_id, true,curr_bed_type); + this->placeholder_parser().set("bbl_bed_temperature_gcode", new ConfigOptionBool(false)); this->placeholder_parser().set("bed_temperature_initial_layer", new ConfigOptionInts(*first_bed_temp_opt)); this->placeholder_parser().set("bed_temperature", new ConfigOptionInts(*bed_temp_opt)); - this->placeholder_parser().set("bed_temperature_initial_layer_single", new ConfigOptionInt(first_bed_temp_opt->get_at(initial_extruder_id))); + this->placeholder_parser().set("bed_temperature_initial_layer_single", new ConfigOptionInt(target_bed_temp)); this->placeholder_parser().set("bed_temperature_initial_layer_vector", new ConfigOptionString()); this->placeholder_parser().set("chamber_temperature",new ConfigOptionInts(m_config.chamber_temperature)); this->placeholder_parser().set("overall_chamber_temperature", new ConfigOptionInt(max_chamber_temp)); + this->placeholder_parser().set("enable_high_low_temp_mix", new ConfigOptionBool(!print.need_check_multi_filaments_compatibility())); // SoftFever: support variables `first_layer_temperature` and `first_layer_bed_temperature` this->placeholder_parser().set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt)); @@ -3497,6 +3504,15 @@ int GCode::get_bed_temperature(const int extruder_id, const bool is_first_layer, return bed_temp_opt->get_at(extruder_id); } +int GCode::get_highest_bed_temperature(const bool is_first_layer, const Print& print) const +{ + auto bed_type = m_config.curr_bed_type; + int bed_temp = 0; + for (auto fidx : print.get_slice_used_filaments(is_first_layer)) { + bed_temp = std::max(bed_temp, get_bed_temperature(fidx, is_first_layer, bed_type)); + } + return bed_temp; +} // Write 1st layer bed temperatures into the G-code. // Only do that if the start G-code does not already contain any M-code controlling an extruder temperature. @@ -3509,9 +3525,7 @@ void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &p std::vector temps_per_bed; int bed_temp = 0; if (m_config.bed_temperature_formula.value == BedTempFormula::btfHighestTemp) { - for (auto fidx : print.get_slice_used_filaments(true)) { - bed_temp = std::max(bed_temp, get_bed_temperature(fidx, true, print.config().curr_bed_type)); - } + bed_temp = get_highest_bed_temperature(true, print); } else { bed_temp = get_bed_temperature(first_printing_extruder_id, true, print.config().curr_bed_type); @@ -4207,11 +4221,8 @@ LayerResult GCode::process_layer( // BBS int bed_temp = 0; - if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp) { - for (auto fidx : print.get_slice_used_filaments(false)) { - bed_temp = std::max(bed_temp, get_bed_temperature(fidx, false, m_config.curr_bed_type)); - } - } + if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp) + bed_temp = get_highest_bed_temperature(false,print); else bed_temp = get_bed_temperature(first_extruder_id, false, m_config.curr_bed_type); gcode += m_writer.set_bed_temperature(bed_temp); diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index d420776105..7b171b079f 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -624,6 +624,7 @@ private: std::vector> m_sorted_layer_filaments; // BBS int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const; + int get_highest_bed_temperature(const bool is_first_layer,const Print &print) const; std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1); bool _needSAFC(const ExtrusionPath &path);