diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 5e8e5e5774..91b747853e 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2785,6 +2785,46 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato this->placeholder_parser().set("scan_first_layer", new ConfigOptionBool(false)); } } + { // hold chamber temp for flat print: Flag + double print_area_sum_threshold = 40000.0, pring_hight_threshold = 0.3; // thresholds in mm^2 and mm as units + + double area_sum_temp = 0.0; + coordf_t max_hight_temp = -1.0; + for (ObjectID print_object_ID_t : print.print_object_ids()) { + const PrintObject *print_object = print.get_object(print_object_ID_t); + // object hight + if (!print_object->layers().empty() && print_object->layers().back()->print_z > max_hight_temp) max_hight_temp = print_object->layers().back()->print_z; + // object area + if (!print_object->layers().empty() && print_object->layers().front()->print_z < print.config().initial_layer_print_height + EPSILON && + !print_object->layers().front()->lslices.empty()) { + ExPolygons temp_Expolys = print_object->layers().front()->lslices; + for (ExPolygon &temp_Expoly : temp_Expolys) { area_sum_temp += temp_Expoly.area(); } + } + // suport area + if (!print_object->support_layers().empty() && print_object->support_layers().front()->print_z < print.config().initial_layer_print_height + EPSILON && + !print_object->support_layers().front()->support_islands.empty()) { + ExPolygons temp_Expolys = print_object->support_layers().front()->support_islands; + for (ExPolygon &temp_Expoly : temp_Expolys) { area_sum_temp += temp_Expoly.area(); } + } + // brim area + if (print.m_brimMap.find(print_object_ID_t) != print.m_brimMap.end() && !print.m_brimMap.at(print_object_ID_t).entities.empty()) { // contain brim + for (const ExtrusionEntity *entities_temp : print.m_brimMap.at(print_object_ID_t).entities) { + Polygons temp_Expolys; + entities_temp->polygons_covered_by_spacing(temp_Expolys, 0.0f); + for (Polygon &temp_Expoly : temp_Expolys) { area_sum_temp += temp_Expoly.area(); } + } + } + } + // wipe tower area + if (has_wipe_tower) { + Polygon temp_Expoly = print.wipe_tower_data().wipe_tower_mesh_data->bottom; + area_sum_temp += temp_Expoly.area(); + } + bool hold_chamber_temp_for_flat_print = max_hight_temp > 0 && max_hight_temp < pring_hight_threshold && area_sum_temp > print_area_sum_threshold * 1.0e10; + this->placeholder_parser().set("hold_chamber_temp_for_flat_print", new ConfigOptionBool(hold_chamber_temp_for_flat_print)); + } + + std::string machine_start_gcode = this->placeholder_parser_process("machine_start_gcode", print.config().machine_start_gcode.value, initial_extruder_id); if (print.config().gcode_flavor != gcfKlipper) { // Set bed temperature if the start G-code does not contain any bed temp control G-codes.