chiark / gitweb /
459b1df45adc21ced05c43d05f08d160aff3ad92
[reprap-play.git] / maglite-holder.scad
1 // -*- C -*-
2
3 dxf_off = [ -40, -85 ];
4
5 torch_lit_dia = 37.5;
6 torch_big_dia = 56.5;
7 torch_tot_len = 256;
8 torch_big_len = 60;
9
10 torch_clear = 30;
11 torch_clear_below = 10;
12
13 stem_width = 20;
14 stem_thick = 8;
15
16 torch_recess = 11;
17 arm_width = 10;
18 block_thick = 15;
19
20 torch_out_more = 10;
21
22 brace = [ 40, 20, 20 ];
23
24 hole_dia = 4 + 0.5;
25 hole_slot = 5;
26
27 slop = 2; // total, not each side
28
29 torch_min_xcoord_fig_cm = -2.7; // coordinates of bottom left of curve
30 torch_min_ycoord_fig_cm = -5.9; // & big part in fig file.  mid top is origin
31 torch_smm_xcoord_fig_cm = -1.9; // x coord of lhs of narrow part
32
33 //$fa=5;
34
35 // calculated
36
37 torch_dxf_scale =
38   [ (torch_big_dia - torch_lit_dia) /
39     (-(torch_min_xcoord_fig_cm - torch_smm_xcoord_fig_cm) * 10 * 2),
40     torch_big_len / (-torch_min_ycoord_fig_cm * 10) ];
41
42 echo(torch_dxf_scale);
43
44 above = torch_big_len + torch_clear + torch_clear_below;
45
46 holes = [ 172, 265 ];
47
48 stem_below = stem_width/2;
49
50 stem_len = holes[1] - above + stem_below;
51
52 torch_out = stem_thick + torch_big_dia/2 + torch_out_more;
53
54 block_width = arm_width*2 + torch_big_dia;
55
56 block_out = torch_out + torch_big_dia/2/sqrt(2);
57
58 module TorchOrig(){
59   mirror([0,0,1]){
60     hull(){
61       rotate_extrude()
62         translate([-torch_lit_dia/2, 0])
63         scale(torch_dxf_scale)
64         translate(dxf_off)
65         translate([-torch_smm_xcoord_fig_cm * 10, 0])
66         import(file="maglite-holder-torch-curve.dxf",
67                convexity=10, center=true);
68     }
69     translate([0,0, -1])
70       cylinder(r=torch_lit_dia/2, h= torch_tot_len - torch_big_len + 1);
71   }
72 }
73
74 module Torch(){
75   scale(slop/torch_lit_dia + 1.0)
76     TorchOrig();
77 }
78
79 module ScrewHole(y, rot) {
80   translate([0,0, above -y]){
81     rotate([0,rot,0]){
82       hull(){
83         for (d= [-1,+1] * hole_slot/2) {
84           translate([d,0,0])
85             rotate([90,0,0])
86             translate([0,0,-stem_thick*2])
87             cylinder(r= hole_dia/2, h= stem_thick*4);
88         }
89       }
90     }
91   }
92 }    
93
94 module TorchMovement(){
95   // xxx needs torch increasing for slop
96   translate([0, -torch_out, 0]) {
97     translate([0, 0, -torch_recess])
98       Torch();
99     rotate([90,0,0])
100       linear_extrude(height= block_out)
101       projection() rotate([-90,0,0]) Torch();
102   }
103 }
104
105 module Bracket(){
106   difference(){
107     mirror([0,1,0]) {
108       translate([-stem_width/2, 0, -stem_len])
109         cube([stem_width, stem_thick, stem_len]);
110       translate([0,0, -block_thick]) hull(){
111         translate([-stem_width/2, 0, -brace[2]])
112           cube([stem_width, stem_thick, 1]);
113         translate([-brace[0]/2, 0, 0])
114           cube([brace[0], brace[1], 1]);
115       }
116     }
117     ScrewHole(holes[0], 90);
118     ScrewHole(holes[1], 0);
119   }
120   difference(){
121     mirror([0,1,0])
122       translate([-block_width/2, 0, -block_thick])
123       cube([block_width, block_out, block_thick]);
124     TorchMovement();
125   }
126 }
127
128 module Demo(){
129   color("red")
130     translate([0, -torch_out, 0])
131     TorchOrig();
132   color("blue")
133     translate([0, -torch_out, above])
134     cylinder(r=torch_big_dia/2, h=1);
135   Bracket();
136 }
137
138 Demo();
139