One thing you probably want to be aware of......
That macro depends upon
AS3.Getfield(877) to obtain the current active work offset (G54-G59).
This part of the macro depends upon splitting Activemodal (field 877) into an array.
At this time the array looks as follows:
G0|G17|G40|G50|G54|G64|G69|G90|G98
which translates to:
motion modal|workplane|tool compensation|scale|velocity mode|rotation|distance mode|canned cycle return.
The array puts each of these values into a location, starting at [0] = motion modal (G0, G1, G2, G3 etc)
If the stack changes in the future..... and something is added then this "may" affect your macro.
(I have recommended defining these as individual fields in the past but its been muted given the data can be extracted by other means from field 877)
Such as for instance if G93 is added, then G95 will probably appear in the string too.... making the string a little longer.
Longer is not a problem, just if the stack is changed / increased above (before)array position [4] which is where we check and reset the work co-ordinates back to where they were before the toolchange.
Eg, to create your macro, I used the following thread as the basis of how to parse the 877 field.....
The catch is if you run this code now you find that G68/69 for which this script was created {not required any more as we have a defined function} was in array postition [3] which is now [5] because tool compensation has been added (G40/G41/G42) and also something else was probably added (scale factors?? I can't remember)..... the thing is the stack got longer.
viewtopic.php?f=11&t=644&p=4596&hilit=activemodal#p4596