chiark / gitweb /
4a881a5c04989da0213e3d31d109e3a6b19a9695
[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 include <commitid.scad>
38
39 torch_dxf_scale =
40   [ (torch_big_dia - torch_lit_dia) /
41     (-(torch_min_xcoord_fig_cm - torch_smm_xcoord_fig_cm) * 10 * 2),
42     torch_big_len / (-torch_min_ycoord_fig_cm * 10) ];
43
44 echo(torch_dxf_scale);
45
46 above = torch_big_len + torch_clear + torch_clear_below;
47
48 holes = [ 172, 265 ];
49
50 stem_below = stem_width/2;
51
52 stem_len = holes[1] - above + stem_below;
53
54 torch_out = stem_thick + torch_big_dia/2 + torch_out_more;
55
56 block_width = arm_width*2 + torch_big_dia;
57
58 block_out = torch_out + torch_big_dia/2/sqrt(2);
59
60 module TorchOrig(){
61   mirror([0,0,1]){
62     hull(){
63       rotate_extrude()
64         translate([-torch_lit_dia/2, 0])
65         scale(torch_dxf_scale)
66         translate(dxf_off)
67         translate([-torch_smm_xcoord_fig_cm * 10, 0])
68         import(file="maglite-holder-torch-curve.dxf",
69                convexity=10, center=true);
70     }
71     translate([0,0, -1])
72       cylinder(r=torch_lit_dia/2, h= torch_tot_len - torch_big_len + 1);
73   }
74 }
75
76 module Torch(){
77   scale(slop/torch_lit_dia + 1.0)
78     TorchOrig();
79 }
80
81 module ScrewHole(y, rot) {
82   translate([0,0, above -y]){
83     rotate([0,rot,0]){
84       hull(){
85         for (d= [-1,+1] * hole_slot/2) {
86           translate([d,0,0])
87             rotate([90,0,0])
88             translate([0,0,-stem_thick*2])
89             cylinder(r= hole_dia/2, h= stem_thick*4);
90         }
91       }
92     }
93   }
94 }    
95
96 module TorchMovement(){
97   translate([0, -torch_out, 0]) {
98     translate([0, 0, -torch_recess])
99       Torch();
100     rotate([90,0,0])
101       linear_extrude(height= block_out)
102       projection() rotate([-90,0,0]) Torch();
103   }
104 }
105
106 module Bracket(){ ////toplevel
107   cid_w = stem_width * .75;
108   hole_near = hole_slot + hole_dia;
109
110   difference(){
111     mirror([0,1,0]) {
112       translate([-stem_width/2, 0, -stem_len])
113         cube([stem_width, stem_thick, stem_len]);
114       translate([0,0, -block_thick]) hull(){
115         translate([-stem_width/2, 0, -brace[2]])
116           cube([stem_width, stem_thick, 1]);
117         translate([-brace[0]/2, 0, 0])
118           cube([brace[0], brace[1], 1]);
119       }
120     }
121     ScrewHole(holes[0], 90);
122     ScrewHole(holes[1], 0);
123     translate([-cid_w/2, 0, above - holes[0] - hole_near])
124       rotate([-90,0,0])
125       %Commitid_BestCount([cid_w, holes[1]-holes[0] - hole_near*2]);
126   }
127   difference(){
128     mirror([0,1,0])
129       translate([-block_width/2, 0, -block_thick])
130       cube([block_width, block_out, block_thick]);
131     TorchMovement();
132   }
133 }
134
135 module BracketPrint(){ ////toplevel
136   rotate([-90,0,0])
137     Bracket();
138 }
139
140 module TestTorchPrint(){ ////toplevel
141   intersection(){
142     translate([0,0, torch_lit_dia / 2 / sqrt(2)])
143       rotate([-90,0,0])
144       Torch();
145     translate([-100, -torch_tot_len*2, 0])
146       cube([200, torch_tot_len*4, 200]);
147   }
148 }
149
150 module Demo(){ ////toplevel
151   color("red")
152     translate([0, -torch_out, 0])
153     TorchOrig();
154   color("blue")
155     translate([0, -torch_out, above])
156     cylinder(r=torch_big_dia/2, h=1);
157   Bracket();
158 }
159
160 //Demo();
161 //BracketPrint();
162 //TestTorchPrint();