3D part design with OpenSCAD #101: Using roof to make a tapered countersink screw hole.

2 min read
By Bob
3D part design with OpenSCAD #101: Using roof to make a tapered countersink screw hole.

Making a tapered countersink hole for a screw is pretty easy using roof, here is an example:

//
Taper=true;
Taper_adjust=10;//[.01:.01:100]
recess_size=10;//[0:.01:100]
recess_shape=100;//[3:1:100]
recess_depth=3;//[0:.01:100]
hole_size=10;//[.1:.01:100]
hole_shape=100;//[3:1:100]
hole_depth=50;//[1:.01:100]


module screw_hole(){
  cylinder(h=hole_depth,r1=hole_size/2,r2=hole_size/2,$fn=hole_shape);
  rotate([0,180,0])
  translate([0,0,-hole_depth+recess_depth])
if (Taper){
  resize([0,0,Taper_adjust])
roof(method="straight"){
  rotate([0,180,0])
  circle(d=hole_size+recess_size,$fn=recess_shape);
}}
  translate([0,0,hole_depth])
  translate([0,0,-recess_depth])
  linear_extrude(recess_depth)
  circle(d=hole_size+recess_size,$fn=recess_shape);
}

difference(){
  linear_extrude(hole_depth-.5,convexity=4)
  square(40,center=true);
  render()
  screw_hole();
}

translate([40,0,0])
screw_hole();

Now all I have to do is call the module and specify the coordinates to locate where I want the recessed holes at.

Keep in mind that you need to specify a method > roof(method="straight") < with roof or things may not render properly, there isn't a whole lot of documentation on this but you can have a look at the built in examples to see the different options for roof