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