First of all i am not machining my self in any way, but i am a pretty good software engineer.
My farther is using a Fanuc and had trouble repeating pattern so i decided to help out and build a tool for repeating patterns with out doing any more tool changes than needed.
This small tool will detect all tool changes and repeart the millings in between in both the x and y axis.
https://zanderdk.github.io/GcodeThingy/
one can upload gcode and type in how many parts in x and y direction (x == rows and y == colums), and the pitch/distance between them in both direction and the output gcode will contain GOTO statements looping over every gcode that is inbetween tool changes so it will do any further toolchanges.
please report bugs here: https://github.com/zanderdk/GcodeThingy/issues and i will adress them as quick as possible. This is stil very early alpha so it might not work (but should) with your post processor but it should.
Supporting both Macro A and B.