diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index b75ec61db3..09d283a327 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -2103,7 +2103,7 @@ public: out.push_back(kvp.first); return out; } - bool empty() { return options.empty(); } + bool empty() const { return options.empty(); } // Iterate through all of the CLI options and write them to a stream. std::ostream& print_cli_help( diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index ca80dd3dc2..464d0fe755 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -1008,7 +1008,7 @@ void WipeTower::toolchange_Change( // This is where we want to place the custom gcodes. We will use placeholders for this. // These will be substituted by the actual gcodes when the gcode is generated. //writer.append("[end_filament_gcode]\n"); - writer.append("[toolchange_gcode]\n"); + writer.append("[toolchange_gcode_from_wipe_tower_generator]\n"); // Travel to where we assume we are. Custom toolchange or some special T code handling (parking extruder etc) // gcode could have left the extruder somewhere, we cannot just start extruding. We should also inform the diff --git a/src/libslic3r/GCode/WipeTowerIntegration.cpp b/src/libslic3r/GCode/WipeTowerIntegration.cpp index d8afefdf95..eb06ddd165 100644 --- a/src/libslic3r/GCode/WipeTowerIntegration.cpp +++ b/src/libslic3r/GCode/WipeTowerIntegration.cpp @@ -3,6 +3,8 @@ #include "../GCode.hpp" #include "../libslic3r.h" +#include "boost/algorithm/string/replace.hpp" + namespace Slic3r::GCode { static inline Point wipe_tower_point_to_object_point(GCodeGenerator &gcodegen, const Vec2f& wipe_tower_pt) @@ -81,19 +83,15 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip if (gcodegen.config().wipe_tower) deretraction_str = gcodegen.unretract(); } - - - + assert(toolchange_gcode_str.empty() || toolchange_gcode_str.back() == '\n'); + assert(deretraction_str.empty() || deretraction_str.back() == '\n'); // Insert the toolchange and deretraction gcode into the generated gcode. - DynamicConfig config; - config.set_key_value("toolchange_gcode", new ConfigOptionString(toolchange_gcode_str)); - config.set_key_value("deretraction_from_wipe_tower_generator", new ConfigOptionString(deretraction_str)); - std::string tcr_gcode, tcr_escaped_gcode = gcodegen.placeholder_parser_process("tcr_rotated_gcode", tcr_rotated_gcode, new_extruder_id, &config); - unescape_string_cstyle(tcr_escaped_gcode, tcr_gcode); + boost::replace_first(tcr_rotated_gcode, "[toolchange_gcode_from_wipe_tower_generator]", toolchange_gcode_str); + boost::replace_first(tcr_rotated_gcode, "[deretraction_from_wipe_tower_generator]", deretraction_str); + std::string tcr_gcode; + unescape_string_cstyle(tcr_rotated_gcode, tcr_gcode); gcode += tcr_gcode; - if (! toolchange_gcode_str.empty() && toolchange_gcode_str.back() != '\n') - toolchange_gcode_str += '\n'; // A phony move to the end position at the wipe tower. gcodegen.writer().travel_to_xy(end_pos.cast()); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 806e66b19a..0246280e35 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -5275,8 +5275,6 @@ static std::map s_CustomGcodeSpecificP {"before_layer_gcode", {"layer_num", "layer_z", "max_layer_z"}}, {"layer_gcode", {"layer_num", "layer_z", "max_layer_z"}}, {"toolchange_gcode", {"layer_num", "layer_z", "max_layer_z", "previous_extruder", "next_extruder", "toolchange_z"}}, - // some internal g_code ? - {"tcr_rotated_gcode", {"toolchange_gcode", "deretraction_from_wipe_tower_generator"}}, }; const std::map& custom_gcode_specific_placeholders() @@ -5315,16 +5313,6 @@ CustomGcodeSpecificConfigDef::CustomGcodeSpecificConfigDef() def = this->add("toolchange_z", coFloat); def->label = L(""); def->tooltip = L(""); - - // I'm not sure if next options are really needed - - def = this->add("toolchange_gcode", coString); - def->label = L(""); - def->tooltip = L(""); - - def = this->add("deretraction_from_wipe_tower_generator", coString); - def->label = L(""); - def->tooltip = L(""); } const CustomGcodeSpecificConfigDef custom_gcode_specific_config_def;