diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 7d50dad553..53731324ce 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5431,7 +5431,8 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z) // Process the custom change_filament_gcode. const std::string& change_filament_gcode = m_config.change_filament_gcode.value; std::string toolchange_gcode_parsed; - if (!change_filament_gcode.empty()) { + //Orca: Ignore change_filament_gcode if is the first call for a tool change and manual_filament_change is enabled + if (!change_filament_gcode.empty() && !(m_config.manual_filament_change.value && m_toolchange_count == 1)) { toolchange_gcode_parsed = placeholder_parser_process("change_filament_gcode", change_filament_gcode, extruder_id, &dyn_config); check_add_eol(toolchange_gcode_parsed); gcode += toolchange_gcode_parsed; diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 3299d9e6dc..6896b47127 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -60,6 +60,7 @@ const std::vector GCodeProcessor::Reserved_Tags = { "_GP_LAST_LINE_M73_PLACEHOLDER", "_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER", "_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER", + " MANUAL_TOOL_CHANGE ", "_DURING_PRINT_EXHAUST_FAN" }; @@ -76,7 +77,8 @@ const std::vector GCodeProcessor::Reserved_Tags_compatible = { "_GP_FIRST_LINE_M73_PLACEHOLDER", "_GP_LAST_LINE_M73_PLACEHOLDER", "_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER", - "_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER" + "_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER", + " MANUAL_TOOL_CHANGE " }; @@ -1010,7 +1012,9 @@ void GCodeProcessor::apply_config(const PrintConfig& config) if (spiral_vase != nullptr) m_spiral_vase_active = spiral_vase->value; - + const ConfigOptionBool* manual_filament_change = config.option("manual_filament_change"); + if (manual_filament_change != nullptr) + m_manual_filament_change = manual_filament_change->value; } void GCodeProcessor::apply_config(const DynamicPrintConfig& config) @@ -2108,6 +2112,13 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Width (" << comment << ")."; return; } + // Orca: manual tool change tag + if (m_manual_filament_change && boost::starts_with(comment, reserved_tag(ETags::Manual_Tool_Change))) { + std::string_view tool_change_cmd = comment.substr(reserved_tag(ETags::Manual_Tool_Change).length()); + if (boost::starts_with(tool_change_cmd, "T")) { + process_T(tool_change_cmd); + } + } } // color change tag diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 209a1cc686..353e4160b4 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -260,6 +260,7 @@ namespace Slic3r { Last_Line_M73_Placeholder, Estimated_Printing_Time_Placeholder, Total_Layer_Number_Placeholder, + Manual_Tool_Change, During_Print_Exhaust_Fan }; @@ -637,6 +638,7 @@ namespace Slic3r { bool m_wiping; bool m_flushing; float m_remaining_volume; + bool m_manual_filament_change; //BBS: x, y offset for gcode generated double m_x_offset{ 0 }; diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 67d1b12d8f..1e4ae800d1 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #ifdef __APPLE__ #include @@ -312,7 +313,8 @@ std::string GCodeWriter::update_progress(unsigned int num, unsigned int tot, boo std::string GCodeWriter::toolchange_prefix() const { - return FLAVOR_IS(gcfMakerWare) ? "M135 T" : + return config.manual_filament_change ? ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Manual_Tool_Change) + "T": + FLAVOR_IS(gcfMakerWare) ? "M135 T" : FLAVOR_IS(gcfSailfish) ? "M108 T" : "T"; } diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index e06a263435..5469b3418c 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -818,7 +818,7 @@ static std::vector s_Preset_printer_options { "printer_technology", "printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor", "fan_kickstart", "fan_speedup_time", "fan_speedup_overhangs", - "single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", + "single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", "default_print_profile", "inherits", "silent_mode", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index d3fb5d0327..f911d4391c 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3367,6 +3367,14 @@ def = this->add("filament_loading_speed", coFloats); def->readonly = true; def->set_default_value(new ConfigOptionBool(true)); + def = this->add("manual_filament_change", coBool); + def->label = L("Manual Filament Change"); + def->tooltip = L("Enable this option to omit the custom Change filament G-code only at the beginning of the print. " + "The tool change command (e.g., T0) will be skipped throughout the entire print. " + "This is useful for manual multi-material printing, where we use M600/PAUSE to trigger the manual filament change action."); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool(false)); + def = this->add("purge_in_prime_tower", coBool); def->label = L("Purge in prime tower"); def->tooltip = L("Purge remaining filament into prime tower"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index ee0e761ea0..c5c88373ce 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -944,6 +944,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, machine_start_gcode)) ((ConfigOptionStrings, filament_start_gcode)) ((ConfigOptionBool, single_extruder_multi_material)) + ((ConfigOptionBool, manual_filament_change)) ((ConfigOptionBool, single_extruder_multi_material_priming)) ((ConfigOptionBool, wipe_tower_no_sparse_layers)) ((ConfigOptionString, change_filament_gcode)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index f142412bdc..80fa57835e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3480,6 +3480,8 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) } }); }; + optgroup->append_single_option_line("manual_filament_change"); + optgroup = page->new_optgroup(L("Wipe tower")); optgroup->append_single_option_line("purge_in_prime_tower"); optgroup->append_single_option_line("enable_filament_ramming");