G-Code Decorator

Automatically add corner radii or chamfers to linear toolpaths. Now supports programs containing existing G02/G03 arcs.

in
Supports G01, G02, and G03. Features are applied to corners where two straight lines meet.
Toolpath Visualization
Original
Modified
Modified G-Code Output

How the G-Code Fillet & Chamfer Adder Works

The adder finds sharp corners between straight G01 moves and replaces each one with a tangent arc (a fillet) or a straight cut across the corner (a chamfer). Every other line passes through unchanged.

It reads the program line by line, keeping track of the current X and Y position, and treats each line with an X or Y word as a move from the previous point. The first move is assumed to start at X0 Y0. A corner is only changed when two G01 feed moves in X and Y follow each other directly and neither has a Z word. Rapids, existing arcs and corners separated by any other line, such as a Z move or an M code, are left as they are.

The output starts with a comment and a G90 G17 line with G20 or G21 taken from the Imperial/Metric toggle, and coordinates are written to 4 decimals in inch and 3 in metric.

How It Works

Fillet (Radius R)
θ = angle between the two moves
Setback t = R ÷ tan(θ ÷ 2)
Centre distance = R ÷ sin(θ ÷ 2)
The first move is cut short by t, an arc of radius R is added, and the next move starts t along its own line. The arc centre lies on the line that bisects the corner, so the arc is tangent to both moves. A left turn gets G03 and a right turn G02. On a square corner θ is 90° and t equals R.
Chamfer (Size C)
Setback = C on both moves
Chamfer length = 2 × C × sin(θ ÷ 2)
Both moves are cut back by the size you enter and joined by a straight line. On a square corner this gives a 45° chamfer with legs of C. A corner is left sharp when either move is not longer than the setback.

Worked Examples

Built-in imperial example, fillet 0.125 in
Original
G90 G54 G0 X0 Y0
G1 X2.0 Y0.0 F20.
Y2.0
G3 X4.0 Y2.0 I1.0 J0
G1 X4.0 Y0.0
X0 Y0
Output
( MODIFIED BY CORNER DECORATOR )
G90 G17 G20
G90 G54 G0 X0 Y0
G01 X1.8750 Y0.0000 F20.
G03 X2.0000 Y0.1250 I0.0000 J0.1250 (Radius)
Y2.0
G3 X4.0 Y2.0 I1.0 J0
G01 X4.0000 Y0.1250
G02 X3.8750 Y0.0000 I-0.1250 J-0.0000 (Radius)
X0 Y0
  • The corner at X2 Y0 is a left turn, so it gets G03. The move stops at X1.875 and the arc centre is X1.875 Y0.125.
  • The corners next to the G3 arc are not changed, and the last corner at X0 Y0 stays sharp because no move follows it.
A 60° change of direction, fillet 0.25 in
Original
G0 X0 Y0
G1 X2. F20.
X3. Y1.7320508
Output (moves only)
G01 X1.8557 Y0.0000 F20.
G03 X2.0722 Y0.1250 I0.0000 J0.2500 (Radius)
X3. Y1.7320508
  • The path turns 60°, so the angle between the two moves is θ = 120°.
  • t = 0.25 ÷ tan 60° = 0.1443, so the first move stops at X2 − 0.1443 = X1.8557.
  • The arc ends 0.1443 along the second move at X2.0722 Y0.1250, and its centre is 0.25 straight above the start point.

J-0.0000 in the first output is how the page prints a very small negative zero. The control reads it as zero.

Tips for Using the Results

  • Know whether the path is the tool centre or the part. On a tool-centre path (no G41/G42), an inside corner of the part comes out with the entered radius plus the tool radius, and an outside corner with the entered radius minus the tool radius, or sharp if that is zero or less. With cutter compensation the entered radius is the part radius, and an inside radius smaller than the tool radius will cause a compensation alarm.
  • Set the unit toggle to match the program. The header line writes G20 or G21 from the toggle, so the wrong setting would rescale the whole program.
  • Absolute XY programs only. The page assumes G90 and the XY plane. Incremental G91 moves give wrong corners.
  • Check shortened lines. A line that ends at a modified corner is rewritten with only G01, X, Y and its F word. Any other word on that line, such as an M code or N number, and its comment are dropped.
  • Backplot the output. The preview shows the new path in two dimensions. Load the program into the G-Code 3D Viewer to check it with the Z moves before cutting.

Frequently Asked Questions

A fillet replaces the corner with an arc of the radius you enter, tangent to both moves. A chamfer cuts straight across the corner, starting and ending the size you enter back from the corner along each move, which gives a 45° chamfer on a square corner.

By R ÷ tan(θ ÷ 2), where θ is the angle between the two moves. On a square corner that equals the radius. Sharp corners need a longer setback and shallow ones a shorter setback, and the corner is left sharp if either move is too short.

Only if the program is the part profile and runs with cutter compensation. On a tool-centre path, inside corners get the entered radius plus the tool radius, and outside corners get the entered radius minus the tool radius.

Corners are only changed between two directly consecutive G01 moves in X and Y with no Z word. A corner next to a rapid, an arc, a Z move or any other line is left alone, as is the last corner of a profile because no move follows it, and any corner where a move is shorter than the setback.

No. It assumes absolute G90 coordinates in the XY plane. Convert incremental programs to absolute before using it.

Always backplot the modified program and prove it out with single block and reduced rapids. Check that the radius or chamfer suits your tool and that every line around a modified corner still does what you expect.