G-codePlane SelectionModal group 2Mill

G17, G18 & G19: Plane Selection

G17, G18 and G19 pick the two axes an arc is cut in and leave the third one perpendicular to it. G17 is XY and is what a machining centre wakes up in, G18 is the ZX plane and is what a turning centre wakes up in, G19 is YZ. One of the three is always live. The choice reaches a long way past G02 and G03: on a Fanuc it also sets which axis a canned cycle feeds down, which axis the tool length offset lands on, and the plane cutter compensation does its geometry in. Put the plane word in the safe start block and change it only with the compensations cancelled.

Syntax

G17             XY plane. Arc centre words I and J, Z perpendicular
G18             ZX plane. Arc centre words I and K, Y perpendicular
G19             YZ plane. Arc centre words J and K, X perpendicular

All three are modal and all three sit in the same group, so writing one cancels the other two. None of them takes an address.

Parameters

Nothing is passed to these codes. What they decide is how the rest of the program is read, and the last three rows hold on a Fanuc only where the matching parameter has been set that way.

What the plane decidesUnder G17Under G18Under G19
Arc plane for G02 and G03XYZXYZ
Arc centre wordsI and JI and KJ and K
Perpendicular axis, the one a helix climbsZYX
G02 runs clockwise seen from+Z, looking down at the table+Y+X
Cutter compensation geometry planeXYZXYZ
Canned cycle feed axis, parameter 5101 bit 0 at 1ZYX
Tool length offset axis, compensation type BZYX

Example

O0012 (CAM PLATE, 150 X 60 X 25 6082, SPOTFACE AND RADIUSED GROOVE)
G21 G17 G40 G49 G80 G90          (safe start. G17 is listed because the last job leaves its plane)
T04 M06                          (12mm 3 flute carbide end mill)
G54                              (X0 Y0 at the bottom left corner, Z0 on the top face)
S8000 M03                        (302m/min)
G00 X40. Y30.                    (centre of the 30mm spotface)
G43 H04 Z25. M08                 (length on in G17, so the offset lands on Z. Flood coolant)
G00 Z1.
G01 X49. F1000                   (out to the cutting radius, 30mm bore less the 12mm tool)
G03 I-9. Z-2.5 F800              (helix down 2.5mm a turn, climbing the bore wall)
G03 I-9. Z-5.
G03 I-9. Z-7.5
G03 I-9. Z-10.
G03 I-9.                         (one flat turn to clean the wall)
G01 X40. F2000                   (back to centre, off the wall)
G00 Z25. M09
M05
T05 M06                          (12mm ball nose, 6mm radius)
S9000 M03                        (339m/min)
G00 X63.6 Y30.                   (tool centre at the start of the groove profile)
G43 H05 Z25. M08                 (length applied in G17, before the plane changes)
G18                              (ZX plane. The profile is an arc in X and Z, Y stays put)
G00 Z10.
G01 Z4.8 F400                    (ball drops 1.2mm into stock at the tangent point)
G02 X86.4 Z4.8 I11.4 K15.2 F900  (25mm radius, 5mm deep, 30mm across. I and K here, not I and J)
G00 Z25. M09
G17                              (back to XY before anything else runs)
G49
G91 G28 Z0.                      (home Z)
M30

Controller differences

ControlBehaviour
FanucThree parameters decide how far the plane reaches. Bits 1 and 2 of parameter 3402 set which of the three is live at power-on and after a clear, so the same file starts in a different plane on two machines. Bit 1 of parameter 5001 picks tool length compensation A, which always offsets Z, or B, which offsets the axis perpendicular to the plane. Bit 0 of parameter 5101 does the same job for canned cycles: at 0 the cycle always feeds in Z, at 1 it feeds along the axis the plane leaves out. Changing the plane with G41 or G42 live stops the program with PS0037. A turning centre comes up in G18.
HaasThe mills take all three planes for arcs, and G18 is the default on the lathes. 2D cutter compensation, G41 and G42, works in X and Y with G17, and 3D compensation is a code of its own, G141.
Siemens 840DG17, G18 and G19 are native rather than ISO dialect, and the plane sets the infeed axis, which is the axis the tool length is applied along. By default a plane change moves the length, wear and base dimension components across to the new geometry axes with it. Setting data SD42940 $SC_TOOL_LENGTH_CONST, at any value other than zero, holds the assignment where it is, which is what a turning or grinding tool wants. The drilling cycles take their drilling axis from the plane, not from a parameter.
MazakEIA/ISO programs read all three as on Fanuc. A Mazatrol conversational program has no plane word: the plane belongs to the unit, and the shape coordinates in each unit are read against it.
OkumaOSP applies the plane to coordinate rotation and area machining as well as to arcs, compensation and the fixed cycles. The plane it falls back to is set by the optional parameter for automatic setting at NC reset and power-on, so a reset part way through a G18 job drops the control into G17 and the restart runs the next arc flat.
GrblAll three are in the v1.1 supported list and the parser comes up in G17, but the word reaches nothing beyond arcs. There is no cutter radius compensation and there are no canned cycles, so the plane changes which two axes an arc is cut in and leaves everything else alone.
MarlinThe three codes exist only where CNC_WORKSPACE_PLANES has been uncommented in Configuration_adv.h, and it ships commented out. On stock firmware the plane word is answered as an unknown command and G2 and G3 keep working in XY, so a ZX arc posted to a converted printer is cut as an XY one.

What goes wrong

The tool length lands on the wrong axis and the spindle drives sideways into the fixture. On a Fanuc set for tool length compensation B, bit 1 of parameter 5001, the offset goes on the axis the plane leaves out, so a G43 H04 called while G18 is still live puts 150mm of tool length into Y instead of Z. Call G43 in G17, then change plane.

Next, holes in the side of the part. Bit 0 of parameter 5101 decides whether a canned cycle always feeds in Z or feeds along the perpendicular axis. Two machines running the same file with different settings drill in two different directions, and nothing on the page says which.

Third, compensation and a plane word in the same breath. Fanuc stops with PS0037 when the plane changes with G41 or G42 live, which is the kind outcome, so G40 belongs before the plane word, never after it.

Fourth, the G18 direction trap. Clockwise is defined looking from positive Y, which puts X up the page and Z across it. Sketch the ZX plane the way it feels natural, X across, and every G02 comes out mirrored: a radius that bulges where the drawing wants it hollow.

Last, the plane outlives the program. A safe start block with no plane word in it inherits whatever the previous job finished in, and the state a Fanuc powers up in is parameter 3402, not anything a programmer wrote.

Updated 11 Oct 2026