Troubles with Post Processors

I looked at your pp, a lot to digest there.
Some quick observations that can eliminate confusion on what gcode/text gets posted to the gcode file…

  • use ModalText() carefully, best to not use, rather use Text()
  • use ModalNumber vs. NonModalText() carefully, read this for quick behavior summary. It is important to understand ModalNumber() vs. NonModalNumber(), see the full descriptions in the pp doc link in the pp editor split screen at the bottom and also in Options / Machine / ‘Post processor’ or just point your browser to the doc from the sheetcam install folder such as (file:///C:/Program%20Files%20(x86)/SheetCam%20TNG/Languages/en/HTML/Post%20Processor.htm)
  • sheetcam core/engine (which invokes the pp functions) will manage motion of Z to ‘safeZ’ position, which is defined in Options / Job as ‘Rapid clearance’. You won’t see the code in the pp. It does this after OnPenUp() by modifying endZ to safeZ value, then invoking OnRapid(). Since OnRapid() should be written with ModalNumber() axis keys (" Z" for instance), then the call to OnRapid() will only post the Z axis since endX and endY haven’t changed yet. After that call to OnRapid(), sheetcam core will call it again after having changed endX and endY.

You are largely on the right track with the rest of your pp, good job.
here’s a simple job, pp, and the gcode it produced. Experiment with this.

GRBL plasma v3.scpost (4.3 KB)
p- 3 simple shapes.tap (1.4 KB)
p- 3 simple shapes.job (13.6 KB)