ENH:Object skipping supports skipping flushing of filament change

Jira:[STUDIO-12781]

Change-Id: Ia21d07b0ef107867cce55631d99bd03caebd6387
(cherry picked from commit d74849d499078f87d14282e92f48b2c02355d96c)
This commit is contained in:
weizhen.xie
2025-07-01 20:25:19 +08:00
committed by Noisyfox
parent ffab04262d
commit ca34800cad
10 changed files with 73 additions and 23 deletions

View File

@@ -98,6 +98,7 @@
"10"
],
"support_chamber_temp_control": "1",
"support_object_skip_flush": "1",
"wrapping_exclude_area": [
"145x310",
"256x310",

View File

@@ -102,6 +102,7 @@
"10"
],
"support_chamber_temp_control": "1",
"support_object_skip_flush": "1",
"wrapping_exclude_area": [
"145x310",
"256x310",

View File

@@ -209,6 +209,7 @@
"18"
],
"support_chamber_temp_control": "1",
"support_object_skip_flush": "1",
"wipe_distance": [
"2",
"2"

View File

@@ -213,6 +213,7 @@
"18",
"18"
],
"support_object_skip_flush": "1",
"wipe_distance": [
"2",
"2"

View File

@@ -140,6 +140,7 @@
"single_extruder_multi_material": "1",
"support_air_filtration": "0",
"support_chamber_temp_control": "0",
"support_object_skip_flush": "0",
"wipe": [
"1"
],

View File

@@ -748,8 +748,6 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
gcode += gcodegen.unretract();
}
// BBS: if needed, write the gcode_label_objects_end then priming tower, if the retract, didn't did it.
gcodegen.m_writer.add_object_end_labels(gcode);
double current_z = gcodegen.writer().get_position().z();
if (z == -1.) // in case no specific z was provided, print at current_z pos
@@ -761,6 +759,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
}
// Process the end filament gcode.
bool add_change_filament_624 = false;
std::string end_filament_gcode_str;
if (gcodegen.writer().filament() != nullptr) {
// Process the custom filament_end_gcode in case of single_extruder_multi_material.
@@ -769,7 +768,12 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
if (gcodegen.writer().filament() != nullptr && !filament_end_gcode.empty()) {
DynamicConfig config;
config.set_key_value("layer_num", new ConfigOptionInt(gcodegen.m_layer_index));
end_filament_gcode_str = gcodegen.placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id, &config);
if (!gcodegen.m_filament_instances_code.empty()) {
end_filament_gcode_str += ("M624 " + gcodegen.m_filament_instances_code + "\n");
gcodegen.m_filament_instances_code = "";
add_change_filament_624 = true;
}
end_filament_gcode_str += gcodegen.placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id, &config);
check_add_eol(end_filament_gcode_str);
}
}
@@ -788,6 +792,10 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
std::string toolchange_retract_str = gcodegen.retract(tcr.is_tool_change && !is_nozzle_change, false, auto_lift_type);
check_add_eol(toolchange_retract_str);
//BBS: if needed, write the gcode_label_objects_end then priming tower, if the retract, didn't did it.
std::string object_end_label_temp;
gcodegen.m_writer.add_object_end_labels(object_end_label_temp);
// Process the custom change_filament_gcode. If it is empty, provide a simple Tn command to change the filament.
// Otherwise, leave control to the user completely.
std::string change_filament_gcode = gcodegen.config().change_filament_gcode.value;
@@ -813,8 +821,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
end_filament_gcode_str = nozzle_change_gcode_trans + end_filament_gcode_str;
}
end_filament_gcode_str = toolchange_retract_str + end_filament_gcode_str;
end_filament_gcode_str = toolchange_retract_str + object_end_label_temp + end_filament_gcode_str;
std::string wipe_next_start_point_str;
bool need_travel_after_change_filament_gcode = false; // travel need be after the filament changed to get the correct "m_curr_extruder_id"
if (! change_filament_gcode.empty()) {
DynamicConfig config;
@@ -952,7 +961,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
if (!is_used_travel_avoid_perimeter) {
std::string start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, tool_change_start_pos + plate_origin_2d), erMixed, "Move to start pos");
check_add_eol(start_pos_str);
toolchange_gcode_str += start_pos_str;
wipe_next_start_point_str = start_pos_str;
} else {
// BBS:change travel_path
Vec3f gcode_last_pos;
@@ -980,7 +989,14 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
}
std::string travel_to_wipe_tower_gcode;
Polyline travel_polyline = generate_path_to_wipe_tower(gcode_last_pos2d_object, start_wipe_pos, avoid_bbx, printer_bbx);
for (const auto &p : travel_polyline.points) {
for (size_t i = 0; i < travel_polyline.points.size(); ++i) {
const auto &p = travel_polyline.points[i];
if (i == travel_polyline.points.size() - 1) {
wipe_next_start_point_str = gcodegen.travel_to(p, erMixed, "Move to start pos");
check_add_eol(wipe_next_start_point_str);
break;
}
travel_to_wipe_tower_gcode += gcodegen.travel_to(p, erMixed, "Move to start pos");
check_add_eol(travel_to_wipe_tower_gcode);
}
@@ -1007,10 +1023,14 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
DynamicConfig config;
config.set_key_value("filament_extruder_id", new ConfigOptionInt(new_filament_id));
start_filament_gcode_str = gcodegen.placeholder_parser_process("filament_start_gcode", filament_start_gcode, new_filament_id, &config);
if (add_change_filament_624) {
start_filament_gcode_str += "M625\n";
add_change_filament_624 = false;
}
check_add_eol(start_filament_gcode_str);
}
start_filament_gcode_str = start_filament_gcode_str + toolchange_unretract_str;
start_filament_gcode_str = start_filament_gcode_str + wipe_next_start_point_str + toolchange_unretract_str;
// Insert the end filament, toolchange, and start filament gcode into the generated gcode.
DynamicConfig config;
@@ -4645,6 +4665,7 @@ LayerResult GCode::process_layer(
} // for objects
std::map<unsigned int, std::vector<InstanceToPrint>> filament_to_print_instances;
std::map<unsigned int, std::vector<InstanceToPrint>> filament_to_print_instances_temp;
{
for (unsigned int filament_id : layer_tools.extruders) {
auto objects_by_extruder_it = by_extruder.find(filament_id);
@@ -4653,7 +4674,7 @@ LayerResult GCode::process_layer(
bool has_prime_tower = print.config().enable_prime_tower && print.extruders().size() > 1 &&
((print.config().print_sequence == PrintSequence::ByLayer && print.config().print_order == PrintOrder::Default) ||
(print.config().print_sequence == PrintSequence::ByObject && print.objects().size() == 1));
if (has_prime_tower) {
int plate_idx = print.get_plate_index();
Point wt_pos(print.config().wipe_tower_x.get_at(plate_idx), print.config().wipe_tower_y.get_at(plate_idx));
@@ -4668,6 +4689,9 @@ LayerResult GCode::process_layer(
std::vector<const PrintInstance *> new_ordering = chain_print_object_instances(print_objects, &wt_pos);
std::reverse(new_ordering.begin(), new_ordering.end());
filament_to_print_instances_temp[filament_id] = sort_print_object_instances(objects_by_extruder_it->second, layers, &new_ordering, single_object_instance_idx);
if (has_prime_tower) {
filament_to_print_instances[filament_id] = sort_print_object_instances(objects_by_extruder_it->second, layers, &new_ordering, single_object_instance_idx);
} else {
filament_to_print_instances[filament_id] = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering, single_object_instance_idx);
@@ -4782,6 +4806,12 @@ LayerResult GCode::process_layer(
gcode += generate_skirt(print, print.skirt(), Point(0, 0), layer.object()->config().skirt_start_angle, layer_tools, layer,
extruder_id);
if (m_enable_exclude_object && print.config().support_object_skip_flush.value) {
std::vector<size_t> filament_instances_id;
for (InstanceToPrint &instance : filament_to_print_instances_temp[extruder_id]) filament_instances_id.emplace_back(instance.label_object_id);
m_filament_instances_code = _encode_label_ids_to_base64(filament_instances_id);
}
std::string gcode_toolchange;
if (has_wipe_tower) {
if (!m_wipe_tower->is_empty_wipe_tower_gcode(*this, extruder_id, extruder_id == layer_tools.extruders.back())) {
@@ -7171,6 +7201,7 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
if (by_object)
m_writer.add_object_change_labels(gcode);
bool add_change_filament_624 = false;
if (m_writer.filament() != nullptr) {
// Process the custom filament_end_gcode. set_extruder() is only called if there is no wipe tower
// so it should not be injected twice.
@@ -7182,7 +7213,12 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position().z() - m_config.z_offset.value));
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
config.set_key_value("filament_extruder_id", new ConfigOptionInt(int(get_extruder_id(old_filament_id))));
if (!m_filament_instances_code.empty()) {
gcode += ("M624 " + m_filament_instances_code + "\n");
gcode += placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id, &config);
m_filament_instances_code = "";
add_change_filament_624 = true;
}
check_add_eol(gcode);
}
}
@@ -7393,6 +7429,10 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
config.set_key_value("filament_extruder_id", new ConfigOptionInt(int(new_filament_id)));
gcode += this->placeholder_parser_process("filament_start_gcode", filament_start_gcode, new_filament_id, &config);
if (add_change_filament_624) {
gcode += "M625\n";
add_change_filament_624 = false;
}
check_add_eol(gcode);
}
// Set the new extruder to the operating temperature.

View File

@@ -630,6 +630,7 @@ private:
coordf_t m_nominal_z;
bool m_need_change_layer_lift_z = false;
int m_start_gcode_filament = -1;
std::string m_filament_instances_code;
std::set<unsigned int> m_initial_layer_extruders;
std::vector<std::vector<unsigned int>> m_sorted_layer_filaments;

View File

@@ -1013,7 +1013,7 @@ static std::vector<std::string> s_Preset_printer_options {
"printhost_cafile","printhost_port","printhost_authorization_type",
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke", "thumbnails", "thumbnails_format",
"use_relative_e_distances", "extruder_type", "use_firmware_retraction", "printer_notes",
"grab_length", "physical_extruder_map",
"grab_length", "support_object_skip_flush", "physical_extruder_map",
"cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset",

View File

@@ -2365,6 +2365,9 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat { 0. });
def = this->add("support_object_skip_flush", coBool);
def->set_default_value(new ConfigOptionBool(false));
def = this->add("bed_temperature_formula", coEnum);
def->label = L("Bed temperature type");
def->tooltip = L("This option determines how the bed temperature is set during slicing: based on the temperature of the first filament or the highest temperature of the printed filaments.");

View File

@@ -1259,6 +1259,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionInts, filament_map))
//((ConfigOptionInts, filament_extruder_id))
((ConfigOptionStrings, filament_extruder_variant))
((ConfigOptionBool, support_object_skip_flush))
((ConfigOptionEnum<BedTempFormula>, bed_temperature_formula))
((ConfigOptionInts, physical_extruder_map))
((ConfigOptionIntsNullable, nozzle_flush_dataset))