Ok, this is nuts but, the gcode looks far more reasonable. I didn’t have time to test it today but it’ll work.
Rather than hack the previously hacked KMLaser version of gcodetools I hacked the version that comes pre-installed with Inkscape. It only took maybe half a dozen edits to set an appropriate Z and get rid of the inappropriate for laser Z axis plunge so you can at least manually order the generated paths. Basically do the marking then cut the interior perimeters before the exterior so it stays attached to the stock until the last minute and doesn’t shift.
In Inkscape I setup five layers, from top to bottom; draft, light etch, heavy etch, interior cuts and finally exterior cuts. Each layer has it’s own orientation points to set the Z and passes and, a tool definition for the feedrate. The draft layer is necessary because some of the KMLaser plugins break if orientation points or a tool is present.
Marlin does seem to tolerate G00 instead of G0 and comments wrapped in parentheses so that makes things simpler.
Obligatory rant and credit … this is *TOTALLY NOT* the way to do this.
The layer approach seemed native so I kept that as I’ve also seen it done that way in commercial CAM systems. The gcodetools authors did an exceptional job on the really hairy math, the code is quite good. However, the documentation is practically non-existent (you have to speak Python and read the code to understand how to use it). They did miss a couple of very straightforward computational geometry algorithms that’d make this plugin a breeze to use. The header/footer file that needs to be present in the output directory is just annoying but I do kind of get why they did it that way.
Further testing is indicated.