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