From 97fb6d22dd02785cf3f3a05ef9925f8d558a5490 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 25 Feb 2022 12:20:23 +0100 Subject: [PATCH] Follow-up to 8aefe3fc90687aaa96a0f0fce59d073ad334eb75 Suppress the G-code find / replace substitutions for the non-G-code sections (comment blocks) at the start and at the end of the G-code file. This commit extends the suppressed blocks for G-code find / replace to placeholders for initial / final M73 commands and over the trailing G-code comments. Fixes gcode substitution: replacing comments removes initial and final M73 commands --- src/libslic3r/GCode.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 28d28f71d6..07af48d867 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1202,13 +1202,13 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato } print.throw_if_canceled(); - // Starting now, the G-code find / replace post-processor will be enabled. - file.find_replace_enable(); - // adds tags for time estimators if (print.config().remaining_times.value) file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::First_Line_M73_Placeholder).c_str()); + // Starting now, the G-code find / replace post-processor will be enabled. + file.find_replace_enable(); + // Prepare the helper object for replacing placeholders in custom G-code and output filename. m_placeholder_parser = print.placeholder_parser(); m_placeholder_parser.update_timestamp(); @@ -1498,6 +1498,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write(m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100% file.write(m_writer.postamble()); + // From now to the end of G-code, the G-code find / replace post-processor will be disabled. + // Thus the PrusaSlicer generated config will NOT be processed by the G-code post-processor, see GH issue #7952. + file.find_replace_supress(); + // adds tags for time estimators if (print.config().remaining_times.value) file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Last_Line_M73_Placeholder).c_str()); @@ -1520,10 +1524,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write_format("; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges); file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str()); - // From now to the end of G-code, the G-code find / replace post-processor will be disabled. - // Thus the PrusaSlicer generated config will NOT be processed by the G-code post-processor, see GH issue #7952. - file.find_replace_supress(); - // Append full config, delimited by two 'phony' configuration keys prusaslicer_config = begin and prusaslicer_config = end. // The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer. {