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