OpenSCAD Tutorial

Lesson 5 · Loops and Patterns

Cut a bolt-hole circle

To space holes evenly around a circle, move each hole out to the bolt-circle radius and then rotate it around the center: lesson 2's "move, then rotate" swing, used on purpose.

for (i = [0 : hole_count - 1])
  rotate([0, 0, i * 360 / hole_count])
    translate([bolt_circle_d / 2, 0, -eps])
      cylinder(...);

Common mistake: looping over angles with for (a = [0 : 60 : 360]). Ranges include their end, so this makes seven holes, and the last one sits exactly on top of the first. Loop over the hole index [0 : hole_count - 1] instead.

Your task: the flange has only one bolt hole. Wrap it in a for loop with rotate to make hole_count evenly spaced holes.

Loading the OpenSCAD editor…
Step 14 of 16