Skip to content

Commit 3722c98

Browse files
adele-with-a-blanewei120
authored andcommitted
Re-parse G-code after post-processing scripts for live preview
After post-processing scripts modify the G-code, re-run GCodeProcessor on the modified file so the slicer preview shows the actual post-processed toolpath automatically.
1 parent 57213de commit 3722c98

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/slic3r/GUI/BackgroundSlicingProcess.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,16 @@ void BackgroundSlicingProcess::finalize_gcode()
822822

823823
run_post_process_scripts(m_temp_output_path, false, "File", m_temp_output_path, m_fff_print->full_print_config());
824824

825+
// Re-parse the G-code if post-processing scripts modified it,
826+
// so the preview reflects the post-processed toolpath
827+
const auto *post_process = m_fff_print->full_print_config().opt<ConfigOptionStrings>("post_process");
828+
if (post_process && !post_process->values.empty() && m_gcode_result) {
829+
m_print->set_status(97, _utf8(L("Updating preview with post-processed G-code")));
830+
GCodeProcessor processor;
831+
processor.process_file(m_temp_output_path);
832+
*m_gcode_result = std::move(processor.extract_result());
833+
}
834+
825835
m_print->set_status(100, _utf8(L("Successfully executed post-processing script")));
826836
}
827837

0 commit comments

Comments
 (0)