chiark / gitweb /
screw-recess-test: make shaftlen a parameter (nfc)
[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 module RecessedScrewCutout(shaftdia, recessdia, shaftlen,
19         recessdepth_arg=RecessedScrewCutout_defaultrecessdepth_flat,
20         zbelow=1) {
21   // pass recessdepth_arg=-1 for the default for flat heads
22   // pass recessdepth_arg=-1 for the default for flat heads
23   recessdepth = recessdepth_arg >= 0 ? recessdepth_arg
24     : -recessdepth_arg * recessdia;
25   recesstopz = recessdepth + 0.5*recessdia + 0.1;
26   xblocky = shaftdia + 0.1;
27
28   translate([0,0,-zbelow]) cylinder(r=shaftdia/2, h=shaftlen+zbelow, $fn=20);
29   RecessScrewCutout_RecessCylinder(recessdia,zbelow, recessdepth);
30   intersection(){
31     translate([-recessdia*1.5, -xblocky/2, -zbelow])
32       cube([recessdia*3, xblocky, recesstopz+2+zbelow]);
33     translate([0, -recessdia, recesstopz])
34       rotate([0,135,0]) cube([recessdia, recessdia*2, 10]);
35     RecessScrewCutout_RecessCylinder(recessdia,zbelow, recesstopz+1);
36   }
37 }
38
39 module Test(){
40   difference(){
41     translate([-cubexy/2, -cubexy/2, 0])
42       cube([cubexy,cubexy,cubez]);
43   }
44 }
45
46 module Hole(){
47     RecessedScrewCutout(tests[0][0],
48                         tests[0][1],
49                         shaftz+1);
50 }
51
52 //Test();
53 Hole();