I have a macro for single-profile thread milling that experiences an intermittent bug. I've seen it randomly switch from incremental to absolute positioning. My workaround is to pre-generate the thread milling Gcode, then it works 100%. Attached is the Gcode that calls my VB macro (M5001.m1s) for thread milling. And also attached is the Gcode produced by this macro.
I think the problem is that I don't wait for the machine to complete a Gcode instruction after calling the Code() function. It's really not necessary and would only slow down the overall operation. I used to have it wait after each Gcode instruction, but then the machine would momentarily pause at times. It bothered me, so I removed all the waiting, now I've got this bug.
Just before my VB macro exits and returns control to Mach3, it waits for the machine to stop moving. This is the only wait in the macro. I believe at some point during the operation it is switching to G90 (absolute positioning) where my Gcode is depending on G91 (incremental positioning) to be active. It seems like it might be running a G90 instruction out of order, since that's always the last instruction executed.
Until I figure out what exactly is going on, I will continue to pre-generate my thread milling Gcode.