chiark / gitweb /
c4c2618f3c7c4daeebf33fbc03b8f8166df8de8e
[reprap-play.git] / screw-recess-test.scad
1 // -*- C -*-
2
3 cubez = 12;
4
5 shaftz = cubez;
6
7 tests = [[4 + 0.5,  10 + 1.0]];
8
9 cubexy = 20;
10
11 module RecessScrewCutout_RecessCylinder(recessdia,zbelow, h){
12   translate([0,0,-zbelow]) cylinder(r=recessdia/2, h=h+1, $fn=40);
13 }
14
15 RecessedScrewCutout_defaultrecessdepth_flat = -0.35;
16 RecessedScrewCutout_defaultrecessdepth_hex = -0.70;
17
18 function RecessedScrewCutout_recessdepth(recessdia, recessdepth_arg) =
19   recessdepth_arg >= 0 ? recessdepth_arg : -recessdepth_arg * recessdia;
20
21 module RecessedScrewCutout(shaftdia, recessdia, shaftlen,
22         zbelow=1,
23         recessdepth_arg=RecessedScrewCutout_defaultrecessdepth_flat) {
24   // pass recessdepth_arg=-1 for the default for flat heads
25   // pass recessdepth_arg=-1 for the default for flat heads
26   recessdepth = RecessedScrewCutout_recessdepth(recessdia, recessdepth_arg);
27   recesstopz = recessdepth + 0.5*recessdia + 0.1;
28   xblocky = shaftdia + 0.1;
29
30   translate([0,0,-zbelow]) cylinder(r=shaftdia/2, h=shaftlen+zbelow, $fn=20);
31   RecessScrewCutout_RecessCylinder(recessdia,zbelow, recessdepth);
32   intersection(){
33     translate([-recessdia*1.5, -xblocky/2, -zbelow])
34       cube([recessdia*3, xblocky, recesstopz+2+zbelow]);
35     translate([0, -recessdia, recesstopz])
36       rotate([0,135,0]) cube([recessdia, recessdia*2, 10]);
37     RecessScrewCutout_RecessCylinder(recessdia,zbelow, recesstopz+1);
38   }
39 }
40
41 module Test(){
42   difference(){
43     translate([-cubexy/2, -cubexy/2, 0])
44       cube([cubexy,cubexy,cubez]);
45   }
46 }
47
48 module Hole(){
49     RecessedScrewCutout(tests[0][0],
50                         tests[0][1],
51                         shaftz+1);
52 }
53
54 //Test();
55 Hole();