G-Code Shifter
Shift all X, Y, and Z coordinates in a program by an incremental value. Positive values move the tool path in the positive direction.
Original G-Code
Shifted Result
How the G-Code XYZ Shifter Works
The shifter adds a fixed amount to the X, Y and Z positions in a program, which moves the whole toolpath without changing its shape. A positive shift moves the path in the positive direction of that axis.
Typical uses are moving a job to a different place on the stock, laying out several copies of a part on one plate, or correcting a program that was posted from the wrong origin. The page reads the program line by line and keeps track of the modes that decide what a number means: absolute (G90) or incremental (G91) positioning, and whether a drilling cycle is active. Only absolute part positions are moved. Distances, reference positions, offsets and dwell times are left as they were.
The program is assumed to start in G90. Code written without spaces, such as G1X2.Y3., is read the same way as spaced code.
How It Works
Worked Examples
G90 G54 G17 G0 X0.5 Y0.5 Z0.1 (START X0.5) G1 Z-0.05 F10. G1 X2.25 Y0.5 F20. G2 X2.75 Y1. I0 J0.5 G0 Z1.
G90 G54 G17 G0 X2.000 Y0.250 Z0.1 (START X0.5) G1 Z-0.05 F10. G1 X3.750 Y0.250 F20. G2 X4.250 Y0.750 I0 J0.5 G0 Z1.
- X0.5 + 1.5 = X2.000 and Y1. − 0.25 = Y0.750.
- Z is not shifted, so Z0.1 and Z-0.05 keep their original text. The arc I0 J0.5 and the comment are unchanged.
G90 G54 G17 G0 X1. Y1. Z0.5 G81 X1. Y1. Z-0.25 R0.1 F5. X2. G80 G91 G28 Z0.
G90 G54 G17 G0 X1. Y1. Z1.000 G81 X1. Y1. Z0.250 R0.600 F5. X2. G80 G91 G28 Z0.
- The hole depth and the R plane both rise by 0.5, so the tool still rapids to 0.1 above the new top of the part.
- G91 G28 Z0. is a reference return in incremental mode, so it is not touched.
Dwell lines such as G04 X1.0, G53 machine moves and G10 or G92 settings come through unchanged in the same way. Enter the same values above and you will get the same output.
Tips for Using the Results
- Consider a work offset first. Moving the G54 zero, or a G52 local shift on controls that support it, moves the program without editing it and is easy to undo. Use the shifter when the file itself has to change.
- Check incremental sections. Lines in G91 are left alone, which is right for moves relative to a shifted point. If a G91 section starts from a position that is not in the program, such as a subprogram called from somewhere else, check where it ends up.
- Look at the start of the program. The page assumes G90 until it sees G91. If your program relies on the control already being in G91, add G90 or G91 at the top before shifting.
- Combine with the mirror. To reflect a part about a line other than zero, mirror it with the G-Code Mirror and then shift it by twice the line position.
- Backplot the result. Load it into the G-Code 3D Viewer and check the extremes against your machine travel, vice jaws and clamps.
Frequently Asked Questions
Always backplot the shifted program, check it against your machine travel and fixturing, and prove it out with single block and reduced rapids before cutting.