Keep the bed at first-layer filament temperatures with By Highest Temp

This commit is contained in:
SoftFever committed 2026-10-23 01:42:08 +08:00
1 parent 373ffaa13f
commit 19e42d8dce
2 files changed
+53 -1

No files matched your search

+3 -1
View File
@@ -5501,7 +5501,9 @@ int GCode::get_highest_bed_temperature(const bool is_first_layer, const Print& p
{
auto bed_type = m_config.curr_bed_type;
int bed_temp = 0;
for (auto fidx : print.get_slice_used_filaments(is_first_layer)) {
// Only the filaments printed on the first layer touch the bed, so a filament that starts higher up, such as a
// support interface, must not raise the bed temperature for the rest of the print.
for (auto fidx : print.get_slice_used_filaments(true)) {
bed_temp = std::max(bed_temp, get_bed_temperature(fidx, is_first_layer, bed_type));
}
return bed_temp;
+50
View File
@@ -2,6 +2,7 @@
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/catch_tostring.hpp>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Model.hpp"
@@ -17,6 +18,7 @@
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include <algorithm>
#include <cstddef>
#include <fstream>
#include <ios>
@@ -179,6 +181,54 @@ TEST_CASE("The G-code header names the first object's filament when printing by
CHECK(header_value("first_layer_temperature") == 250);
}
// A filament that starts above the first layer, such as a support interface, never touches the bed. Heating the
// bed to its temperature would soften the filament the part stands on, so only first layer filaments count.
TEST_CASE("The highest temperature bed formula ignores filaments that start above the first layer", "[GCode]")
{
// Filament 1: bed 65 on the first layer, 60 after it. Filament 2: bed 100. A 30 mm cap on a 10 mm tall stem prints
// with filament 1 and is supported from the bed, the support with filament 1 and its interface under the cap
// with filament 2.
TriangleMesh mesh = make_cube(10, 10, 10);
mesh.translate(10, 10, 0);
TriangleMesh cap = make_cube(30, 30, 2);
cap.translate(0, 0, 10);
mesh.merge(cap);
DynamicPrintConfig config = Test::multifilament_config(2, {
{"bed_temperature_formula", "by_highest_temp"},
{"enable_prime_tower", 0},
{"enable_support", 1},
{"support_filament", 1},
{"support_interface_filament", 2},
{"supertack_plate_temp_initial_layer", "65,100"},
{"cool_plate_temp_initial_layer", "65,100"},
{"textured_cool_plate_temp_initial_layer", "65,100"},
{"eng_plate_temp_initial_layer", "65,100"},
{"hot_plate_temp_initial_layer", "65,100"},
{"textured_plate_temp_initial_layer", "65,100"},
{"supertack_plate_temp", "60,100"},
{"cool_plate_temp", "60,100"},
{"textured_cool_plate_temp", "60,100"},
{"eng_plate_temp", "60,100"},
{"hot_plate_temp", "60,100"},
{"textured_plate_temp", "60,100"},
{"skirt_loops", 0},
{"brim_type", "no_brim"},
});
const std::string gcode = Test::slice({mesh}, config);
REQUIRE(gcode.find("\nT1") != std::string::npos);
std::vector<int> bed_temps;
std::istringstream lines(gcode);
for (std::string line; std::getline(lines, line);)
if (line.rfind("M140 S", 0) == 0 || line.rfind("M190 S", 0) == 0)
bed_temps.push_back(std::stoi(line.substr(6)));
INFO("bed temperatures: " << Catch::Detail::stringify(bed_temps));
REQUIRE_FALSE(bed_temps.empty());
CHECK(bed_temps.front() == 65);
CHECK(std::find(bed_temps.begin(), bed_temps.end(), 60) != bed_temps.end());
CHECK(std::find(bed_temps.begin(), bed_temps.end(), 100) == bed_temps.end());
}
TEST_CASE("Object label comments number each object and copy with or without exclude object", "[GCode]")
{
// repetier has no exclude-object commands, so set_object_info() writes nothing for it.