QIDISlicer facilitates straightforward G-Code post-processing through the specification of find and replace pairs, accompanied by optional regex matching, case sensitivity, and whole word matching—mirroring the functionalities offered by popular text editors.
Regular expressions constitute a highly potent and adaptable tool capable of setting up even intricate substitutions. For more elaborate post-processing requirements, users can opt to utilize an external post-processing script.
The feature accessible from Print Settings -> Output options.
The G-Code undergoes processing prior to previewing, ensuring that your modifications are visible in the G-Code preview. Enabling 'Verbose G-Code' can be advantageous as it generate additional annotations, which can then be matched using regex.
Pre-regular match | After regular matching |
QIDISlicer supports Perl-compatible regular expression syntax, as outlined in boost Perl regular expression syntax. Here, the "single line" modifier mimics Perl's s/ modifier. When regular expressions are enabled, the "Replace with" pattern supports the "extended" syntax detailed in boost extended format syntax. The regular expression engine supports Lookahead and lookbehind assertions, albeit only for fixed-length patterns. When regular expressions are disabled, placeholders such as n, r, t, and others are supported in both "Find" and "Replace with" patterns, similar to Notepad++'s "extended" syntax.
The G-code find/replace post-processor processes G-code in blocks, generating a single block for each layer, starting from the Z-move up to the transition to the subsequent layer. Multiple find/replace patterns are sequentially applied to a single G-code block before processing the next. Matching multi-line patterns is feasible but confined within a single G-code block, typically within a single layer. Regular expressions, while powerful, can be tricky; hence, we recommend using the 101 online playground to familiarize yourself with regex. Remember to switch the regex flavor to ECMAScript in the regex101 online playground.
A compelling illustration of a sophisticated G-code modification using a relatively complex regular expression: increasing the extrusion rate of top solid infill from the default 95% to 98%.
(;TYPE:Top solid infilln)(.*?)(;TYPE:|$)(?!Top solid infill)
${1}M221 S98n${2}M221 S95n${3}