Not sure what all that code is all about. It should be as simple as setting the G54 position, setting the tool length offsets, and pressing the green button.
You should never never NEVER have to edit g-code manually !!! Your post processor can be adjusted to output exactly what you need.
The beginning of my programs look like this so you can see that whatever the machine's offsets determine G54 to be is used in the program.
I am guessing you may have to make some post processor adjustments to get the correct output for your machine. How confident are you that you have a suitable post processor for the machine ?
Code:
%
O0000 (TR1896-4D)
(FADAL FANUC MPMASTER 3 AXIS VMC )
(MACHINE GROUP-1)
(MASTERCAM - V13.)
(MCX FILE - C:\MCX\TR1896\TR1896-4\TR1896-4D.MCX)
(POST - FADALFANUC_MPMASTER_VMC)
(PROGRAM - TR1896-4D.NC)
(DATE - FEB-19-2010)
(TIME - 12:00 PM)
(T18 - .750 INS MILL - H18 - D18 - D0.7500")
(T7 - .250 CAR BEM - H7 - D7 - D0.2500" - R0.1250")
(OVERALL MIN DEPTH = Z-.5)
N100 G00 G17 G20 G40 G80 G90
N110 G91 G28 Z0.
N120 (WCS NAME - TOP)
N130 (TOOLPATH GROUP - TR1896-4D)
N140 (COMPENSATION TYPE - COMPUTER)
/ N150 G0 G90 G54.1 P1 X0 Y0
N160 T18 M06 ( .750 INS MILL)
N170 (MIN DEPTH = Z-.5)
N180 (TOOLPATH - ROUGHPOCK)
N190 (STOCK LEFT ON DRIVE SURFS = 0.)
N200 G00 G17 G90 G54 X-1.5985 Y-.9221 S6000 M03
N210 G43 H18 Z2.
N220 M07
N230 Z.075
N240 G94 G01 Z-.025 F40.
N250 X-.82 Y-.875 F80.
N260 Y.875
N270 G02 X-.375 Y1.32 I.445 J0.
N280 G01 X.375
N290 G02 X.82 Y.875 I0. J-.445
N300 G01 Y-.875
N310 G02 X.375 Y-1.32 I-.445 J0.
N320 G01 X-.375
N330 G02 X-.82 Y-.875 I0. J.445
N340 G01 X-.599 Y-.5709