diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index d9f907f03..dc017f737 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1034,6 +1034,15 @@ void GCode::_do_export(Print &print, FILE *file) } _write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100% _write(file, m_writer.postamble()); + + // adds tags for time estimators + if (print.config().remaining_times.value) + { + _writeln(file, GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag); + if (m_silent_time_estimator_enabled) + _writeln(file, GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag); + } + print.throw_if_canceled(); // calculates estimated printing time diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 461b4cd35..4b4e9f587 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -171,6 +171,8 @@ namespace Slic3r { const std::string GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag = "; NORMAL_FIRST_M73_OUTPUT_PLACEHOLDER"; const std::string GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag = "; SILENT_FIRST_M73_OUTPUT_PLACEHOLDER"; + const std::string GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag = "; NORMAL_LAST_M73_OUTPUT_PLACEHOLDER"; + const std::string GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag = "; SILENT_LAST_M73_OUTPUT_PLACEHOLDER"; GCodeTimeEstimator::GCodeTimeEstimator(EMode mode) : _mode(mode) @@ -306,9 +308,17 @@ namespace Slic3r { sprintf(time_line, time_mask.c_str(), "0", _get_time_minutes(_time).c_str()); gcode_line = time_line; } + // replaces placeholders for final line M73 with the real lines + else if (((_mode == Normal) && (gcode_line == Normal_Last_M73_Output_Placeholder_Tag)) || + ((_mode == Silent) && (gcode_line == Silent_Last_M73_Output_Placeholder_Tag))) + { + sprintf(time_line, time_mask.c_str(), "100", "0"); + gcode_line = time_line; + } else gcode_line += "\n"; + // add remaining time lines where needed _parser.parse_line(gcode_line, [this, &it_line_id, &g1_lines_count, &last_recorded_time, &time_line, &gcode_line, time_mask, interval](GCodeReader& reader, const GCodeReader::GCodeLine& line) diff --git a/src/libslic3r/GCodeTimeEstimator.hpp b/src/libslic3r/GCodeTimeEstimator.hpp index ef91d5ff1..1fbc1c14b 100644 --- a/src/libslic3r/GCodeTimeEstimator.hpp +++ b/src/libslic3r/GCodeTimeEstimator.hpp @@ -19,6 +19,8 @@ namespace Slic3r { public: static const std::string Normal_First_M73_Output_Placeholder_Tag; static const std::string Silent_First_M73_Output_Placeholder_Tag; + static const std::string Normal_Last_M73_Output_Placeholder_Tag; + static const std::string Silent_Last_M73_Output_Placeholder_Tag; enum EMode : unsigned char {