Supported G-Codes and M-Codes

What CutViewer draws, what it reads without drawing, and what it doesn't support yet.

CutViewer is built for 3-axis milling and routing programs: Fanuc- and Haas-style mill code, GRBL, LinuxCNC and Mach3. It draws moves in X, Y and Z, and checks the program for problems as it reads it. Each code below falls into one of three groups:

  • Drawn: shown in the 3D view and counted in the run time.
  • Read, not drawn: CutViewer understands the code and keeps track of it, but it changes nothing in the drawing, or depends on values only your machine knows, such as offsets and tool lengths.
  • Not supported: ignored. Anything on the line that CutViewer does understand is still used.

Motion

Code What it does In CutViewer
G00 Rapid move Drawn
G01 Straight feed move Drawn
G02, G03 Clockwise and counter-clockwise arcs, with I/J/K or R, including helical arcs with a Z move Drawn

Canned cycles

Code What it does In CutViewer
G81, G82, G83, G73 Drilling, drilling with dwell, peck drilling, high-speed peck Drawn: rapid to the hole, rapid to R, feed to depth, rapid out
G84, G74 Right- and left-hand tapping Drawn, feeding back out of the hole
G85, G89 Boring, feeding out Drawn, feeding back out of the hole
G76, G86, G87, G88 Other boring cycles Drawn as a drilling cycle
G80 Cancel the cycle Read
G98, G99 Return to the initial Z or the R plane Read, used for the retract height

Cycles work in absolute (G90) and incremental (G91) mode, and L or K repeats a hole. Pecks (Q) and dwells (P) inside a cycle are not drawn separately.

Modes

Code What it does In CutViewer
G17, G18, G19 Arc plane XY, XZ or YZ Read, used for arcs
G20, G21 Inch or millimetre units Read. A warning appears if neither comes before the first move
G90, G91 Absolute or incremental positions Read
G90.1, G91.1 Absolute or incremental arc centres (I/J/K) Read
G93, G94, G95 Inverse-time, per-minute or per-revolution feed Read, used for the run time
G54 to G59 Work offsets Read, shown in the status bar. Offset values aren't applied, so everything is drawn in program coordinates
G40, G41, G42 Cutter radius compensation Read and shown, but not applied. The path is drawn as programmed
G43, G49 Tool length offset Read, not applied. Z is drawn as programmed
G97 Spindle speed in RPM Read

Codes whose axis words aren't drawn

On these lines, X, Y and Z are not a move CutViewer can place, so nothing is drawn. The next move starts from the last position CutViewer knows.

Code What it does
G04 Dwell. Lines are listed so you can jump between them
G28, G30 Return to a reference position
G53 Move in machine coordinates
G92 Set the current position. The shift isn't applied to later moves
G10 Set offsets or tool data
G52 Local coordinate offset
G68, G51 Rotation and scaling (not applied)
G43.1 Dynamic tool length (GRBL, LinuxCNC)
G65 Macro call

M-codes

Code What it does In CutViewer
M03, M04 Spindle on Read. Cutting with the spindle off is a warning
M05 Spindle off Read
M06 with T Tool change Read. Fills the Tools list with each tool's lines and time
M00, M01, M02, M30 Stops and program end Read
M07, M08, M09 Coolant Read, no effect on the drawing

Words and comments

  • X, Y, Z: positions. I, J, K and R: arc centres and radius. F: feed rate. S: spindle speed. T: tool number.
  • R, Q, P, L, K in canned cycles: R plane, peck depth, dwell and repeats.
  • N line numbers and O program numbers are allowed and ignored.
  • Comments in ( ) and after ; are ignored, as are % lines. Tool descriptions in comments from Fusion 360, CamBam, Mastercam and the original CutViewer are read for the Tools list.
  • Words don't need spaces (G0X10Y5 works), and lowercase is fine.

Not supported yet

  • Rotary axes (A, B, C): ignored. 4th- and 5th-axis programs are drawn as their X, Y and Z moves only.
  • Lathe programs: there is no lathe mode, so diameter programming, U/W incremental words and constant surface speed (G96) aren't applied.
  • Subprograms and macros: M98/M99 calls and O-word subroutines aren't followed, and variables such as #1 aren't evaluated.
  • Offsets and transforms: work offset values, G92 shifts, cutter compensation, tool lengths, rotation (G68) and scaling (G51) aren't applied.
  • Controller-specific cycles, such as circular pocketing (G12/G13), threading and probing cycles.

Files open from .nc, .tap, .ngc, .gcode, .cnc, .txt, .mpf, .eia and .min, and anything else that is plain text G-code. See CNC file types.

Something missing that your machine uses? Let us know and include a sample file if you can.