What Is a Toolpath?
The path a CNC tool follows, the common types, and how to check one before you cut.
A toolpath is the route a cutting tool follows while a CNC machine makes a part. It's every move the machine makes: down into the material, along the edges, across the pockets, up to a safe height and over to the next feature. Your CAM program calculates the toolpath from the design, the tool and the cutting settings. The machine never sees the toolpath itself, only the G-code program that describes it.
Most toolpaths describe where the center of the tool goes. On the bottom of the cut that point is the tool's tip; for a flat end mill it's the center of its flat bottom. Because the cutter has a radius, the path runs half a tool diameter away from the edge it's cutting.
Rapid moves and cutting moves
Every toolpath is made of two kinds of move:
- Rapid moves (G0) position the tool as fast as the machine can go. They should only happen above the material, at a safe height.
- Feed moves (G1 for straight lines, G2 and G3 for arcs) cut at the programmed feed rate.
A viewer draws the two in different colors, which makes the most dangerous mistake easy to spot: a rapid move that goes through the material instead of over it.
Common toolpath types
CAM programs offer dozens of toolpath strategies, but most are variations on these:
- Facing skims the top of the stock flat, usually in back-and-forth passes with a large tool.
- Contour or profile follows the outline of a shape, inside or outside, to cut it out or finish its walls. Deep profiles are cut in several step-downs, with tabs to hold the part in place if it's being cut free.
- Pocket clears all the material inside a boundary to a set depth, in offset rings or back-and-forth passes.
- Adaptive or high-speed (HSM) clearing removes material in curved passes that keep the tool's engagement constant, so you can cut deeper and faster with less wear on the tool.
- Drilling moves to each hole position and drills it, often written as a canned cycle such as G81, G82 or G83.
- 3D roughing and finishing machine curved surfaces. Roughing removes the bulk of the material in layers; finishing passes such as parallel (raster) and scallop follow the surface with a small stepover, usually with a ball end mill.
- Engraving and V-carving follow lines or text. A V-carve varies the depth of a V-bit so the cut gets wider where the letter is wider.
An example toolpath
This short program uses three of the types above on a 50 × 30 mm part. A 6 mm end mill faces the top 0.5 mm deep in zigzag passes, then cuts a 2 mm deep profile around the outside with rounded corners. A 5 mm drill then drills three holes with a G81 cycle.
(Toolpath example: face, profile and drill a 50 x 30 mm part)
(Origin at the lower-left corner of the part, top of the stock is Z0)
G21 G17 G90 G54
T1 M6 (6 mm flat end mill)
S12000 M3
G0 X-5 Y2 Z10
(Facing: zigzag passes 0.5 mm deep, 5 mm apart)
G0 Z2
G1 Z-0.5 F300
G1 X55 F800
G1 Y7
G1 X-5
G1 Y12
G1 X55
G1 Y17
G1 X-5
G1 Y22
G1 X55
G1 Y27
G1 X-5
G0 Z10
(Profile: 5 mm corner radius, 2 mm deep, tool centre 3 mm outside the part)
G0 X5 Y-3
G0 Z2
G1 Z-2 F300
G1 X45 F600
G3 X53 Y5 I0 J8
G1 Y25
G3 X45 Y33 I-8 J0
G1 X5
G3 X-3 Y25 I0 J-8
G1 Y5
G3 X5 Y-3 I8 J0
G0 Z10
M5
T2 M6 (5 mm drill)
S3000 M3
(Drilling: three holes 6 mm deep)
G0 X15 Y15 Z10
G81 X15 Y15 Z-6 R2 F150
X25
X35
G80
G0 Z25
M5
M30
Rapids and cutting moves are drawn in different colors, so you can see the tool lift to Z10 between each operation.
Notice the profile coordinates: the part runs from X0 to X50, but the tool center runs from X-3 to X53, 3 mm outside. That's the 6 mm tool's radius, and it's what makes the edge of the cutter land on the edge of the part.
How CAM turns a design into a toolpath
- You choose the operation (pocket, profile, drill and so on), the geometry it applies to, and the tool.
- You set the cutting parameters: depth, step-down, stepover, feed rate, spindle speed, and the heights for clearance and retract.
- CAM calculates the toolpath and shows it on screen, so you can simulate it against the stock.
- The post processor writes the G-code. It turns the toolpath into the exact dialect your controller expects (Grbl, Mach3, LinuxCNC, Fanuc, Haas and so on) and saves it as a .nc, .tap or .gcode file.
The post processor matters: the same toolpath posted for the wrong controller can run differently, or not at all.
Tool center vs part edge: cutter compensation
Almost all CAM output follows the tool center, with the tool radius already built into the coordinates. The alternative is cutter compensation: the program follows the edge of the part, and G41 or G42 tells the controller to offset the path by the radius stored in its tool table. That's common on industrial machines because the operator can adjust a part's size, or account for a resharpened tool, without reposting the program. Hobby controllers such as Grbl don't support cutter compensation, so their programs always follow the tool center.
Why check a toolpath before you cut
CAM simulates the toolpath it calculated, but what runs on the machine is the G-code file, after the post processor and any hand edits. Checking that file catches problems such as:
- Rapids into the material, from a retract height set too low or a move edited by hand.
- The wrong depth, from a Z zero set on the table instead of the top of the stock, or the other way round.
- The wrong units: an inch program read as millimeters, or the reverse, makes a part 25.4 times too small or too large.
- A missing feed rate or spindle start, so the tool cuts at a default speed or with the spindle off.
- The wrong tool or post processor, which shows up as moves in odd places or a part that's the wrong size.
In CutViewer you can open the file, see every move in 3D, step through the program line by line and read the Job panel: part size and X/Y/Z extents, estimated run time, the tools used, and pre-flight checks for problems such as a feed move with no feed rate, cutting with the spindle off or a rapid below Z0.
Frequently Asked Questions
What is a toolpath in CNC machining?
A toolpath is the route the cutting tool follows while it machines a part. CAM software calculates it from your design, the tool and the cutting settings, and a post processor writes it out as G-code moves for the machine.
What is the difference between a toolpath and G-code?
The toolpath is the motion itself; G-code is how that motion is written down for a particular machine. The same toolpath can be posted as G-code for different controllers, and you can draw a G-code program to see its toolpath.
Does a toolpath follow the edge of the part or the center of the tool?
Usually the center of the tool. CAM offsets the path by the tool radius so the edge of the cutter lands on the edge of the part. Some programs instead follow the part edge and let the controller offset it with cutter compensation (G41 and G42).
How can I check a toolpath before running it?
Open the G-code in a viewer such as CutViewer. It draws every move in 3D, shows rapids and cutting moves in different colors, gives the part size and depth, and flags problems like a feed move with no feed rate or a rapid below Z0.
What is an adaptive toolpath?
An adaptive (or high-speed) toolpath keeps the amount of tool engagement roughly constant by cutting in curved, overlapping passes rather than straight ones. That lets you cut deeper at higher feed rates with less wear on the tool. Fusion 360 calls it Adaptive Clearing; other CAM programs use names such as Dynamic or HSM.