Developer ToolsFree generatorPDF, Excel, Word exportMachining

Fanuc Bolt Hole Circle Macro Generator

A bolt hole circle is one of the most common patterns a CNC programmer writes, and calculating each X and Y by hand is slow and error prone. This generator builds a Fanuc Macro B program that uses polar coordinates and a WHILE loop so only a few values need to change.

Fill in

Generated code
Download:

Bolt hole circle program

O1201 (BOLT HOLE CIRCLE, 6 HOLES ON R40.0)
G90 G54 G17 G40 G49 G80
T5 M6
S2400 M3
G0 X0.0 Y0.0
G43 H5 Z50.0
M8
(HOLE PATTERN DATA)
#1=0 (HOLE COUNTER)
#2=6 (NUMBER OF HOLES)
#3=0.0 (START ANGLE)
#4=360/#2 (ANGLE STEP)
G52 X0.0 Y0.0 (SHIFT LOCAL ORIGIN TO CIRCLE CENTER)
G90 G16 (POLAR COORDINATE MODE)
WHILE [#1 LT #2] DO1
G81 X40.0 Y[#3+#1*#4] Z-18.0 R2.0 F220.0
#1=#1+1
END1
G80 G15 (CANCEL CYCLE AND POLAR MODE)
G52 X0 Y0 (CANCEL LOCAL SHIFT)
G0 Z50.0
M9
M5
G91 G28 Z0
G28 Y0
M30
%

Review before running. G52 and G16 behavior, the polar origin, and WHILE support (Macro B option) depend on your control and parameters. Prove out in single block with the machine locked or with the Z axis raised. For a peck cycle, replace G81 with G83 and add a Q value. Dwell, spot drilling and chamfer operations are not included.

NC program control in your ERP

Optional: a conversation on controlling NC program revisions against part and routing data.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter the circle center, radius, number of holes, start angle and drilling data. The program appears on the right, ready to copy or export. Check the tool number, work offset and safe Z for your machine, then prove it out with a dry run before drilling any parts.

  • Center is in the active work coordinate system
  • Start angle is measured from the positive X axis
  • Angle step is 360 divided by the number of holes
  • Replace G81 with G83 for deep holes

How the program works

G52 temporarily moves the local origin to the circle center so polar mode can work about that point. G16 then reads X as the radius and Y as the angle in degrees, so every hole becomes a radius and an angle. The WHILE loop adds one angle step each pass and calls the drilling cycle, which stays modal.

Checking the result

For six holes at a 40 mm radius starting at zero degrees, holes fall every 60 degrees, with the first at X40 Y0 and the second at X20 Y34.641 relative to center. Confirm a couple of positions by hand, then verify with a graphic simulation or a first piece inspection against the drawing.

Common mistakes

Forgetting to cancel G16 and G52 at the end of the pattern is the most dangerous error, since the following moves would still be interpreted in polar mode. Others include incorrect angle direction on mirrored setups, using the wrong plane (G17 is required), and starting the loop from a position inside the part.

Frequently Asked Questions

What is G16 used for?

G16 turns on polar coordinate command mode on Fanuc controls. In G90 the first axis word is the radius and the second is the angle from the positive axis of the selected plane. G15 cancels it.

Does this work on a Haas control?

Haas supports G65 macros, WHILE loops and a G-code for bolt hole circles (G70, G71, G72), but G16 polar behavior and G52 differ. Use this output as a pattern and adapt it, or use the built-in bolt hole cycles.

How do I rotate the pattern?

Change the start angle. For six holes a start angle of 30 degrees puts holes at 30, 90, 150 and so on. Use a negative angle step in the code if the drawing requires counter-clockwise numbering.

Can I use it with a peck drilling cycle?

Yes. Replace G81 with G83 and add a Q value, for example Q3.0, to the same block. Check the peck and retract parameters on your control, since some use parameter 5114 for the retract amount.

If you want NC programs generated and reviewed against ERP routings and approved tools, we can discuss how that could work with human approval.