Gcode postprocessing scripts to supercharge Klipper macros

I’ve finally gotten around to publishing a couple of postprocessing scripts I’ve been working on to take advantage of the power of Klipper macros. I’m collecting them here: GitHub - theophile/gcode-postprocessing-scripts: My personal gcode postprocessing scripts for PrusaSlicer/SuperSlicer

The headliner is one that implements my version of “purge to infill” for multimaterial prints. It rearranges the gcode on either side of filament changes, groups all the “invisible” features (such as supports and infill) together and moves them to right after the filament change, then calculates the total amount of filament that will be used on those “invisible” features and reports it to Klipper so it can deduct that amount from the purge volume during the filament change.

I also have a script that excises the hash symbol from hexadecimal color codes so Klipper doesn’t confuse them for comments, and that looks ahead to get the coordinates of the first travel move after the filament change and reports this to Klipper for use in the filament change macro.

These are pretty specific to my system but I added a LOT of comments to them, so hopefully others will still be able to get some use out of them.

3 Likes