feat: Re-parse G-code after post-processing scripts for live preview#9920
Open
adele-with-a-b wants to merge 1 commit intobambulab:masterfrom
Open
feat: Re-parse G-code after post-processing scripts for live preview#9920adele-with-a-b wants to merge 1 commit intobambulab:masterfrom
adele-with-a-b wants to merge 1 commit intobambulab:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Post-Processing Script Preview
After slicing with post-processing scripts configured, the G-code is automatically re-parsed so the preview shows the post-processed toolpath. No need to export and drag the file back in.
Problem
Currently, when post-processing scripts (configured in Process Settings → Post-processing Scripts) modify the G-code after slicing, the slicer preview still shows the original unmodified toolpath. Users have to manually export the G-code and drag it back into the slicer to see the actual post-processed result.
This is especially painful for scripts like BrickLayers that modify layer Z-heights for interlocking — the whole point is to visually verify the interlocking pattern before printing.
Solution
In
BackgroundSlicingProcess::finalize_gcode(), afterrun_post_process_scripts()completes, re-runGCodeProcessor::process_file()on the modified G-code and replacem_gcode_resultwith the new result. The existingon_process_completed→update_fff_scene()→reload_print()path then picks up the post-processed data and renders it in the preview.The re-parsing only runs when post-processing scripts are configured and non-empty, so there is zero impact on normal slicing without scripts.
Implementation
10 lines added to one file.