chiark / gitweb /
e6bfe32c666eff4475d50a9e7adcc128c82418b6
[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
32 $fa=5;
33
34 // calculated
35
36 torch_dxf_scale =
37   [ torch_big_dia / (-torch_min_xcoord_fig_cm * 10 * 2),
38     torch_big_len / (-torch_min_ycoord_fig_cm * 10) ];
39
40 echo(torch_dxf_scale);
41
42 above = torch_big_len + torch_clear + torch_clear_below;
43
44 holes = [ 172, 265 ];
45
46 stem_below = stem_width/2;
47
48 stem_len = holes[1] - above + stem_below;
49
50 torch_out = stem_thick + torch_big_dia/2 + torch_out_more;
51
52 block_width = arm_width*2 + torch_big_dia;
53
54 block_out = torch_out + torch_big_dia/2/sqrt(2);
55
56 module TorchOrig(){
57   mirror([0,0,1]){
58     hull(){
59       rotate_extrude()
60         scale(torch_dxf_scale)
61         translate(dxf_off)
62         import(file="maglite-holder-torch-curve.dxf",
63                convexity=10, center=true);
64     }
65     translate([0,0, -1])
66       cylinder(r=torch_lit_dia/2, h= torch_tot_len - torch_big_len + 1);
67   }
68 }
69
70 module Torch(){
71   scale(slop/torch_lit_dia + 1.0)
72     TorchOrig();
73 }
74
75 module ScrewHole(y, rot) {
76   translate([0,0, above -y]){
77     rotate([0,rot,0]){
78       hull(){
79         for (d= [-1,+1] * hole_slot/2) {
80           translate([d,0,0])
81             rotate([90,0,0])
82             translate([0,0,-stem_thick*2])
83             cylinder(r= hole_dia/2, h= stem_thick*4);
84         }
85       }
86     }
87   }
88 }    
89
90 module TorchMovement(){
91   // xxx needs torch increasing for slop
92   translate([0, -torch_out, 0]) {
93     translate([0, 0, -torch_recess])
94       Torch();
95     rotate([90,0,0])
96       linear_extrude(height= block_out)
97       projection() rotate([-90,0,0]) Torch();
98   }
99 }
100
101 module Bracket(){
102   difference(){
103     mirror([0,1,0]) {
104       translate([-stem_width/2, 0, -stem_len])
105         cube([stem_width, stem_thick, stem_len]);
106       translate([0,0, -block_thick]) hull(){
107         translate([-stem_width/2, 0, -brace[2]])
108           cube([stem_width, stem_thick, 1]);
109         translate([-brace[0]/2, 0, 0])
110           cube([brace[0], brace[1], 1]);
111       }
112     }
113     ScrewHole(holes[0], 90);
114     ScrewHole(holes[1], 0);
115   }
116   difference(){
117     mirror([0,1,0])
118       translate([-block_width/2, 0, -block_thick])
119       cube([block_width, block_out, block_thick]);
120     TorchMovement();
121   }
122 }
123
124 module Demo(){
125   color("red")
126     translate([0, -torch_out, 0])
127     TorchOrig();
128   color("blue")
129     translate([0, -torch_out, above])
130     cylinder(r=torch_big_dia/2, h=1);
131   Bracket();
132 }
133
134 Demo();
135