G-code reference

G18: XZ plane selection

G18 is xZ plane selection. Selects the XZ (or ZX) plane; the normal plane on a lathe. It is modal, so it stays active on the following lines until another code from the same group replaces it.

What G18 does

G18 puts arcs and compensation in the XZ plane. It is the default on lathes, where all turning arcs lie in X and Z. On a mill it is used for arcs cut on the side of a part.

TypeG-code
MachineMill and lathe
GroupPlane
ModalYes: stays active until replaced by another code from the same group

G18 example

G18 G03 X30. Z-15. R5.

Arc in the XZ plane.

WordWhat it means here
G18XZ plane selection
G03Circular interpolation, counterclockwise
X30.X axis target (on a lathe, the diameter)
Z-15.Z axis target or depth
R5.arc radius, or the R plane (retract height) in a drilling cycle, or a cycle setting

Codes people confuse with G18

CodeWhat it does instead
G17 XY plane selection. Selects the XY plane for arcs and cutter compensation.
G19 YZ plane selection. Selects the YZ plane for arcs and compensation.

Other codes in the plane group

Only one code from a modal group is active at a time. Programming any of these replaces G18.

  • G17 XY plane selection
  • G19 YZ plane selection

Meanings follow the common Fanuc-style standard that Haas, Okuma (EIA mode), Mitsubishi, LinuxCNC and most other controls share for this code. Options and parameters change details from machine to machine, so check the manual for your control.

Quick check: G18

  1. What does G18 do? (Mill and lathe)

  2. Which code: Selects the XZ (or ZX) plane; the normal plane on a lathe.(Mill and lathe)

  3. What does G17 do? (Mill)

Show the answers
  1. Selects the XZ (or ZX) plane; the normal plane on a lathe.
  2. G18
  3. Selects the XY plane for arcs and cutter compensation.

Drill this code with the rest of the core set

More practice hubs

Frequently asked questions

What does G18 mean in CNC programming?
XZ plane selection. Selects the XZ (or ZX) plane; the normal plane on a lathe.
Is G18 modal?
Yes. G18 belongs to the plane group and stays active until another code from that group is programmed.
What is the difference between G18 and G17?
G18 (xZ plane selection): selects the XZ (or ZX) plane; the normal plane on a lathe. G17 (xY plane selection): selects the XY plane for arcs and cutter compensation.
What is the difference between G18 and G19?
G18 (xZ plane selection): selects the XZ (or ZX) plane; the normal plane on a lathe. G19 (yZ plane selection): selects the YZ plane for arcs and compensation.

G-Code Sprint is an educational practice tool only. It is not a CNC simulator, machine controller, safety manual, or replacement for instruction. Always follow your instructor, employer, machine manual, and shop procedures.

Free preview · no card Try G-Code Sprint