ENH: add max print z in placeholder

jira: none

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I55caf23b11cc0194f9c155364e6bb02e298f9392
(cherry picked from commit 724c9b0eb5e73517c921ea809bb7f7e82325130b)
This commit is contained in:
xun.zhang 2025-06-06 14:47:49 +08:00 committed by Noisyfox
parent d6a8f881de
commit b636bbaf2f

View file

@ -2608,6 +2608,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->placeholder_parser().set("in_head_wrap_detect_zone", !intersection_pl(project_polys, {head_wrap_detect_zone}).empty());
}
{
coordf_t max_print_z = 0;
for (auto& obj : print.objects()) {
max_print_z = std::max(max_print_z, (*std::max_element(obj->layers().begin(), obj->layers().end(), [](Layer* a, Layer* b) { return a->print_z < b->print_z; }))->print_z);
}
this->placeholder_parser().set("max_print_z", new ConfigOptionInt(std::ceil(max_print_z)));
}
BoundingBoxf mesh_bbox(m_config.bed_mesh_min, m_config.bed_mesh_max);
auto mesh_margin = m_config.adaptive_bed_mesh_margin.value;
mesh_bbox.min = mesh_bbox.min.cwiseMax((bbox.min.array() - mesh_margin).matrix());