LinuxCNC T

T is the LinuxCNC G-code word that prepares the machine to change to tool x. It does not change the tool by itself; the change occurs when M6 is programmed, either on the same line or a later line. Only the most recent T word applies at the next tool change.

Source checked5/5 values · 2026-10-26

Specification

1 source
Languagegcode
CodeT
Grouptool
SyntaxTx
DialectLinuxCNC

Parameters

NameDescription
xTool number to prepare for the next tool change; the change itself occurs at M6.

Study notes

  • The T word may appear on the same line as M6 or on a previous line; T words may also appear on several lines with no tool change occurring.
  • Only the most recent T word takes effect at the next tool change.
  • On machines whose carousel moves when a T word is programmed, placing the T word several lines before the tool change saves time; a common practice is to put the next tool's T word on the line after a tool change.
  • Rapid moves after T<n> are not shown in the AXIS preview until after a feed move; this applies to machines that travel long distances to change tools, such as a lathe.
  • To turn off that preview behaviour for the current program, program a G1 without any move after the T<n>.
  • With a nonrandom toolchanger (RANDOM_TOOLCHANGER setting in EMCIO), T0 gets special handling and no tool is selected, which can leave the spindle empty after a tool change.
  • With a random toolchanger, T0 has no special treatment and is a valid tool like any other; using T0 to track an empty pocket makes the machine behave like a nonrandom toolchanger and unloads the spindle.

Safety

  • It is an error to use a negative T number.
  • It is an error to use a T number that does not appear in the tool table file, with the exception that T0 on nonrandom toolchangers is accepted.
↑↓ navigate↵ openesc close