If your slicer does not have a mirror operation or a scale that allows negative values then mirroring in the G-code should be straightforward.
As long as your printer doesn't have certain specific tool change or homing or purge positions that are done in the G-code you can just transform it, otherwise you would want to skip these sections and just do the model data (it should be obvious looking at the code where model data starts).
In order to mirror it you just need to swap out the X coordinates in your G-code, If (0,0) is the center of your bed, as is often (but not always) the case for delta printers you will just want to negate the X, so G1 X30 Y-3 Z2
becomes G1 X-30 Y-3 Z2
. If your coordinates have (0,0) in a corner (often the case for orthogonal printers) then you want to subtract X from the maximum X value. for instance if your bed is 250 mm wide then in G1 X30 Y10 Z3 X30
becomes X(250-30)
or G1 X220 Y10 Z3
.
There is only one caveat, some slicers will switch to relative movement using G91
for certain operations and then back to absolute with G90
, so you will want to look out for these. Between a G91
and a G90
you will want to negate the X, no matter where the origin of your printer is.
When writing your script, I'd keep track of the minimum and maximum values encountered and the new minimum and maximum values and print them at the end as a sanity check so you can see if anything is wonky.