From 5076a3008ab085d4196ee9ef1be2b2b2766911a7 Mon Sep 17 00:00:00 2001 From: "wenjie.guo" Date: Thu, 27 Jul 2023 15:37:38 +0800 Subject: [PATCH] NEW: insert Gcode between objects Change-Id: Iec3535941390bfbd279a5677c352d92f36506d4c Signed-off-by: wenjie.guo (cherry picked from commit e0c5476e2e4c02055fb6ce7b4b4d927498c6ee90) --- src/libslic3r/GCode.cpp | 9 +++------ src/libslic3r/Preset.cpp | 2 +- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 9 +++++++++ src/libslic3r/PrintConfig.hpp | 3 ++- src/slic3r/GUI/Tab.cpp | 10 ++++++++++ 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 17b3e81c3..78ff18c1c 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1012,8 +1012,7 @@ namespace DoExport { if (ret.size() < MAX_TAGS_COUNT) check(_(L("Before layer change G-code")), config.before_layer_change_gcode.value); if (ret.size() < MAX_TAGS_COUNT) check(_(L("Layer change G-code")), config.layer_change_gcode.value); if (ret.size() < MAX_TAGS_COUNT) check(_(L("Change filament G-code")), config.change_filament_gcode.value); - //BBS - //if (ret.size() < MAX_TAGS_COUNT) check(_(L("Printing by object G-code")), config.printing_by_object_gcode.value); + if (ret.size() < MAX_TAGS_COUNT) check(_(L("Printing by object G-code")), config.printing_by_object_gcode.value); //if (ret.size() < MAX_TAGS_COUNT) check(_(L("Color Change G-code")), config.color_change_gcode.value); if (ret.size() < MAX_TAGS_COUNT) check(_(L("Pause G-code")), config.machine_pause_gcode.value); if (ret.size() < MAX_TAGS_COUNT) check(_(L("Template Custom G-code")), config.template_custom_gcode.value); @@ -1993,10 +1992,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato // another one, set first layer temperatures. This happens before the Z move // is triggered, so machine has more time to reach such temperatures. m_placeholder_parser.set("current_object_idx", int(finished_objects)); - // BBS: remove printing_by_object_gcode - // std::string printing_by_object_gcode = this->placeholder_parser_process("printing_by_object_gcode", print.config().printing_by_object_gcode.value, - // initial_extruder_id); - std::string printing_by_object_gcode; + std::string printing_by_object_gcode = this->placeholder_parser_process("printing_by_object_gcode", print.config().printing_by_object_gcode.value, + initial_extruder_id); // Set first layer bed and extruder temperatures, don't wait for it to reach the temperature. this->_print_first_layer_bed_temperature(file, print, printing_by_object_gcode, initial_extruder_id, false); this->_print_first_layer_extruder_temperatures(file, print, printing_by_object_gcode, initial_extruder_id, false); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index cab5ccb6d..ce913de8e 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -846,7 +846,7 @@ static std::vector s_Preset_machine_limits_options { static std::vector s_Preset_printer_options { "printer_technology", "printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor", - "single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "layer_change_gcode", "change_filament_gcode", + "single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode","printing_by_object_gcode","before_layer_change_gcode", "layer_change_gcode", "change_filament_gcode", "printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_max_radius","extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", "default_print_profile", "inherits", "silent_mode", diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 85e6d9f9b..97dd62d24 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -87,6 +87,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "deretraction_speed", "close_fan_the_first_x_layers", "machine_end_gcode", + "printing_by_object_gcode", "filament_end_gcode", "post_process", "extruder_clearance_height_to_rod", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 692da86f2..7709b7e8f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1021,6 +1021,15 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n")); + def = this->add("printing_by_object_gcode", coString); + def->label = L("Between Object Gcode"); + def->tooltip = L("Insert Gcode between objects. This parameter will only come into effect when you print your models object by object"); + def->multiline = true; + def->full_width = true; + def->height = 12; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionString("")); + def = this->add("filament_end_gcode", coStrings); def->label = L("End G-code"); def->tooltip = L("End G-code when finish the printing of this filament"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 862f6f2ff..5220449a5 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -819,7 +819,8 @@ PRINT_CONFIG_CLASS_DEFINE( PRINT_CONFIG_CLASS_DEFINE( GCodeConfig, - ((ConfigOptionString, before_layer_change_gcode)) + ((ConfigOptionString, before_layer_change_gcode)) + ((ConfigOptionString, printing_by_object_gcode)) ((ConfigOptionFloats, deretraction_speed)) //BBS ((ConfigOptionBool, enable_arc_fitting)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 289bb7b20..5a487575b 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3129,6 +3129,16 @@ void TabPrinter::build_fff() option.opt.is_code = true; option.opt.height = gcode_field_height;//150; optgroup->append_single_option_line(option); + + optgroup = page->new_optgroup(L("Printing by object G-code"), L"param_gcode", 0); + optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { + validate_custom_gcode_cb(this, optgroup, opt_key, value); + }; + option = optgroup->get_option("printing_by_object_gcode"); + option.opt.full_width = true; + option.opt.is_code = true; + option.opt.height = gcode_field_height; // 150; + optgroup->append_single_option_line(option); #if 0 optgroup = page->new_optgroup(L("Before layer change G-code"), 0); optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {