G-code bolt hole circle generator

Writes an example drilling program for holes spaced evenly round a pitch circle diameter (PCD), using a G81 drill cycle or a G83 peck cycle, and reads it back to draw the holes.

Example code – check it and dry-run it, at your own risk. This program is a generic example, not written for your machine or control. Read every line against your control’s manual, simulate it, then run it above the work in single block with reduced rapids and feed before cutting. Check the work offset, tool length offset, units and clearance heights. See the terms of use.
How it works, guides and notes

How it works

Hole i sits at angle θ = start + i × 360°/N, so X = centre X + (PCD/2)·cos θ and Y = centre Y + (PCD/2)·sin θ. Positions are rounded to 0.001 mm (or 0.0001 in). The first line of the cycle carries Z, R, Q and F; most controls then drill one hole for each following X/Y line until G80 cancels the cycle.

G98 makes the drill return to the height it started from (the safe Z) between holes, which clears clamps. G99 would return only to the R plane. On many lathes G98 and G99 mean something else (feed per minute and per revolution). See the G-code reference.

Hand check: 6 holes on a 100 mm PCD starting at 3 o’clock: (50.000, 0.000), (25.000, 43.301), (−25.000, 43.301), (−50.000, 0.000), (−25.000, −43.301), (25.000, −43.301). 43.301 = 50 × sin 60°.

Need the positions only, or a chord for dividers? Use the PCD calculator.

FANUC, Haas, Siemens, Heidenhain, LinuxCNC and Grbl are names or trademarks of their respective owners. They are mentioned only to describe which controls a code format relates to. Lathe Calculator is not affiliated with or endorsed by any of them. Trademarks.

Spotted a mistake? Report an error.