Skip to content

CNC G-code viewer: where the cutter cuts and how much travel is wasted

Paste the G-code of a milling program and get a top view coloured by type of move. Below are the lengths of cutting, rapids, plunges and air cutting, and an estimate of the time.

Part of Pro, 15 EUR a month.

What a G-code viewer is

The EduFacturing CNC G-code viewer is an online tool, part of Pro, that draws the cutter path from a G-code program and measures how much of it is cutting, rapid moves, plunging in Z and air cutting. The view is from above, in the XY plane.

The program is read modally, which means the state carries from line to line. A line with only X50 continues the previous move, so the type of a segment depends on the state, not on one line: G0 is a rapid, a feed move only downward in Z is a plunge, and any other feed move is cutting.

The field comes with a sample two-pass pocket program. The calculations run in the browser.

CNC G-code viewer: a sample 60 × 40 mm pocket program in the G-code field, top surface Z 0, rapid 8000 mm/min, and a top view with an orange cutting outline
CNC G-code viewer: a sample 60 × 40 mm pocket program in the G-code field, top surface Z 0, rapid 8000 mm/min, and a top view with an orange cutting outline

What you see: the cutter path, cutting and rapids

Draws the cutter path by type of move

Cutting is orange, and rapids are grey and dashed. Plunging in Z is red in the legend, but in a top view it is a point and is read from the number. Each type can be switched on and off, and Y is flipped so the part is not mirrored.

Measures five numbers

The length of cutting, rapids, plunging in Z and air cutting, plus a time estimate split into cutting and rapid.

Shows air cutting

A feed move at or above the top surface of the workpiece is drawn semi-transparent and added up separately. A rapid is not counted as waste.

Says which checks were not done

Without a rapid speed the time is not calculated, and without a top surface air cutting is not measured. With a plunge, two more are added: the plunge feed has no numeric check in the rules core, and the cutter type is not in G-code.

When you need to preview G-code

The path of a program is easier to judge on a drawing than in hundreds of lines.

  • Previewing G-code before the machine

    A programmer looks at a CAM program: the order of operations, where the path doubles back for nothing, and whether there is air cutting.

  • Comparing two versions of a program

    A reordered sequence of moves shows up as less air cutting, and another retract height changes the rapid length and the time.

  • A lesson on G0 and G1

    A student writes a few lines and sees a rapid and a cut differ on the drawing, while plunging shows in the numbers.

  • Estimating machine time

    The figure is a lower bound, because acceleration is not calculated. It suits comparing variants, not promising a deadline to a customer.

How the lengths and the time are worked out

The program is first read modally, then every move becomes a segment, and the segments are added up by type.

  1. Read

    The module shared with the G-code checker carries the state through the lines: G0 or G1, G90 or G91, the feed F and the position.

  2. Segments

    A segment exists only when X, Y and Z are known at both ends, so the first moves, until the position is complete, have no segment.

The formulas and rules in the tool
Applies toFormulaMeaning
Segment lengthL = √(Δx² + Δy² + Δz²)in the units of the program; arcs are measured along the chord
PlungeΔx = 0, Δy = 0, Δz < 0, at feedonly downward in Z; a feed segment with Δx or Δy is cutting
Air cuttingfeed and z_from ≥ Z and z_to ≥ ZZ is the top surface you enter; rapids are not counted
Time estimatet = 60·(Σ L / F + L_rapid / v)F is the feed of the segment, v is the rapid in mm/min; for the sample at v = 8000: 47 s

Air cutting as a number, not a feeling

  • Air cutting is a number, not a feeling

    Two versions of one program are compared by the millimetres cut above the workpiece.

  • The estimate does not pretend to be exact

    Instead of a number it shows “not calculated” when there is no rapid speed or there is cutting without a feed.

What it does not do

The view is from above, in the XY plane. The tool axis is drawn without its diameter, and depth shows only in the Z extents: two passes at different depths look like one. Time does not model acceleration, deceleration and the controller's look-ahead, so the real time is longer.

Arcs G2 and G3 are drawn as a straight line from start to end and measured along the chord, so a program with many arcs looks shorter. Cycles G81 to G89 and subprograms are not expanded. A program in inches (G20) is not converted: numbers are in the units of the program, shown as mm.

Questions about the G-code viewer

How to view G-code for a milling program?

Paste the program into the field and get a top view. Cutting is orange, rapids are grey and dashed, and below are the lengths of each type of move and the time estimate.

How to read G-code from the drawing?

Every move becomes a segment with a type. G0 is a rapid (grey, dashed), a feed move only downward in Z is a plunge (a point in the top view), and any other feed move is cutting (orange). The path of the tool axis is drawn, without the cutter diameter.

What is air cutting?

A feed move whose two ends are at or above the top surface of the workpiece you entered. It cuts nothing but moves at cutting speed. Rapids are not counted.

Why is plunging separate from cutting?

A feed move only downward in Z loads the cutter at its end, not on the side, so it has its own number. In the top view it is a point. The plunge feed and the cutter type are unchecked.

How accurate is the time estimate?

It is the length divided by the feed, plus the rapid length divided by the speed you enter. Acceleration is not calculated, so the real time is longer. The estimate is for comparing two versions of one program.

How much does it cost, and how do I get access?

The G-code viewer is part of Pro at 15 EUR a month. Pro also opens the other Pro tools in the catalog.

The G-code viewer is part of Pro

Pro costs 15 EUR a month and opens all 45 Pro tools.

See the path of your program

Part of Pro, 15 EUR a month.