chiark / gitweb /
belt-slot-cut-jig: MaybeRoundedCube utility, nfc
[reprap-play.git] / belt-slot-cut-jig.scad
1 // -*- C -*-
2
3 // todo
4 //  various registration marks
5 //   protrustions at ends at strap width and middle
6 //   grooves on top face at 1/4,1/2,3/4 length and 1/2 width
7
8 crewpunch_slop = 0.3;
9
10 holder_min_wall = 2;
11 holder_attach_near_wall = 5;
12
13 holder_attach_xsz = 5;
14 holder_ctie_width = 4.0 + 0.5;
15 holder_ctie_thick = 3.0 + 0.5;
16 holder_attach_walls = 3;
17 holder_attach_roof = 2.5;
18
19 jig_interval = 25;
20 strap_width = 26.75 + 0.7;
21 strap_thick = 3;
22 edgewall_width = 3;
23
24 punch_travel = 8;
25
26 main_slop = 0.5;
27
28 jig_max_len = 160; // print diagonally
29 //jig_max_len = 30;
30
31 registrationgroove_width = 0.8;
32 registrationgroove_depth = 1.2;
33
34 registrationprotrusion_poke = 3;
35 registrationprotrusion_slope = 0.75;
36
37 jig_overlap = 1;
38
39 // from careful measurement
40
41 crewpunch_shape =
42   [[  6, [0.6, 6.0], [1.6, 12.3] ],
43    [  8, [1.1, 6.2], [1.9, 12.5] ],
44    [ 10, [1.6, 6.5], [2.1, 12.8] ],
45    [ 12, [1.8, 6.6], [2.3, 12.7] ],
46    [ 14, [2.1, 6.8], [2.6, 13.0] ],
47    [ 16, [2.4, 6.9], [2.7, 13.2] ],
48    [ 18, [2.5, 7.0], [2.9, 13.3] ],
49    [ 22, [3.1, 7.1], [3.2, 13.4] ],
50    [ 26, [3.3, 7.2], [3.5, 13.6] ], 
51    ];
52
53 crewpunch_shaft_max_y = 7.5;
54
55 crewpunch_systematic_size_error = +0.36;
56
57 crewpunch_smallest_shape = crewpunch_shape[0];
58 crewpunch_biggest_shape = crewpunch_shape[len(crewpunch_shape)-1];
59
60 crewpunch_skew_angle = 3.5; //degrees
61 crewpunch_skew_yoff = +1.1; //mm
62
63 // computed
64
65 punch_dx = 0.5 * (-crewpunch_biggest_shape[2][0]
66                   +crewpunch_biggest_shape[2][1]);
67 punch_dy = 0.5 * (+crewpunch_biggest_shape[1][1]
68                   -crewpunch_biggest_shape[1][0]) + crewpunch_skew_yoff;
69
70 attach_ysz = holder_attach_walls*2 + holder_ctie_width;
71
72 holder_block_zsz = crewpunch_biggest_shape[0] - crewpunch_smallest_shape[0];
73 holder_xsz = crewpunch_biggest_shape[2][0] + crewpunch_biggest_shape[2][1] +
74   holder_min_wall*2;
75
76 holder_skewangle_yextra = holder_xsz/2 * sin(abs(crewpunch_skew_angle));
77
78 holder_max_y = punch_dy + crewpunch_biggest_shape[1][0] + holder_min_wall
79   + crewpunch_systematic_size_error + holder_skewangle_yextra;
80
81 holder_attach_max_y = punch_dy
82   - max(crewpunch_biggest_shape[1][1], crewpunch_shaft_max_y)
83   - crewpunch_systematic_size_error - holder_skewangle_yextra;
84
85 holder_block_min_y = punch_dy
86   - crewpunch_biggest_shape[1][1] - holder_attach_near_wall +
87   - crewpunch_systematic_size_error - holder_skewangle_yextra;
88
89 holder_all_min_y = holder_attach_max_y - attach_ysz;
90
91 jig_max_y = max(holder_max_y + main_slop, strap_width/2) + edgewall_width;
92 jig_min_y = min(holder_all_min_y - main_slop, -strap_width/2) - edgewall_width;
93
94 jig_main_zsz = holder_block_zsz + punch_travel;
95
96 jig_ends_extra = 2;
97
98 //jig_iters = (jig_max_len - jig_ends_extra) / jig_interval;
99 jig_iters=2;
100 echo(jig_iters);
101
102 // objects
103
104 module CrewPunch(){
105   ourslop = crewpunch_slop - crewpunch_systematic_size_error;
106   hull(){
107     for(layer=crewpunch_shape){
108       translate([0,0, layer[0]]){
109         for(xind=[0,1]) //translate([xind?0:1,0,0])
110           for(yind=[0,1]) //translate([0,yind?0.5:0,0])
111             mirror([xind?1:0,0,0]) mirror([0,yind?0:1,0]){
112               translate([-0.1,-0.1,-0.1])
113                 cube([0.1 + layer[2][xind] + ourslop,
114                       0.1 + layer[1][1-yind] + ourslop,
115                       0.2]);
116             }
117       }
118     }
119   }
120 }
121
122 module MaybeRoundedCube(sizes, roundedness){
123   if (roundedness > 0) {
124     translate([roundedness, roundedness, 0]){
125       minkowski(){
126         cube([sizes[0] - roundedness*2,
127               sizes[1] - roundedness*2,
128               sizes[2]]);
129         cylinder(h=0.05, r=roundedness, $fn=20);
130       }
131     }
132   } else {
133     cube(sizes);
134   }
135 }
136
137 module PunchHolder(cutouts=true){
138     difference(){
139       translate([-holder_xsz/2, holder_block_min_y, 0])
140         cube([holder_xsz,
141               holder_max_y - holder_block_min_y,
142               holder_block_zsz]);
143       if (cutouts)
144         rotate([0,0,-crewpunch_skew_angle])
145         translate([punch_dx,
146                    punch_dy,
147                    -crewpunch_smallest_shape[0]])
148           CrewPunch();
149     }
150     difference(){
151       translate([-holder_attach_xsz/2, holder_all_min_y, 0])
152         cube([holder_attach_xsz,
153               attach_ysz,
154               holder_block_zsz + punch_travel
155               + holder_ctie_thick + holder_attach_roof + 1]);
156       if (cutouts)
157         translate([-30,
158                    holder_all_min_y + holder_attach_walls,
159                    holder_block_zsz + punch_travel])
160           cube([60, holder_ctie_width, holder_ctie_thick]);
161     }
162 }
163
164 module RegistrationGroove(l){
165   // runs along the +ve X axis for length l but at correct z pos
166   translate([0, 0, jig_main_zsz + 0.1]) {
167     rotate([90,0,90])
168       linear_extrude(height=l)
169       polygon([[-registrationgroove_width/2, 0],
170                [ +registrationgroove_width/2, 0],
171                [ 0, -registrationgroove_depth ]]);
172   }
173 }
174
175 module OneJig(){
176   difference(){
177     translate([-(jig_interval/2 + jig_overlap),
178                jig_min_y,
179                -strap_thick])
180       cube([jig_interval + 2,
181             jig_max_y - jig_min_y,
182             jig_main_zsz + strap_thick]);
183     minkowski(){
184       cube([main_slop*2, main_slop*2, 50], center=true);
185       PunchHolder(false);
186     }
187     translate([-100, -strap_width/2, -10])
188       cube([200, strap_width, 10]);
189    translate([-100,0,0])
190      RegistrationGroove(200);
191    for (xfrac=[-1/4,0,+1/4])
192      translate([jig_interval * xfrac, -100, 0])
193        rotate([0,0,90])
194        RegistrationGroove(200);
195   }
196 }
197
198 module RegistrationProtrusion(){
199   // points towards the positive x axis
200   xsz = registrationprotrusion_poke;
201   ysz = registrationprotrusion_poke;
202   diag_sz = xsz * sqrt(2);
203   zsz = diag_sz / registrationprotrusion_slope;
204   hull(){
205     translate([0, 0, 0.1]){
206       linear_extrude(height=0.1)
207         polygon([[   0, -ysz ],
208                  [ xsz,    0 ],
209                  [   0,  ysz ]]);
210       translate([-0.1, 0, zsz ])
211         rotate([0,0,45])
212         cube(0.1);
213     }
214   }
215 }
216
217 module Jig(){
218   for(end=[0,1]){
219     for(yfrac=[-1/2, 0, 1/2]){
220       translate([ end
221                   ? jig_interval * (jig_iters - 0.5)
222                   : -jig_interval/2,
223                  yfrac * strap_width,
224                  0])
225         rotate([0,0, end ? 0 : 180])
226         translate([ jig_overlap, 0, 0 ])
227         RegistrationProtrusion();
228     }
229   }
230   for (i=[0:jig_iters-1]) {
231     translate([jig_interval * i, 0, 0])
232       OneJig();
233   }
234 }
235
236 module JigT(){ ////toplevel
237   rotate([0,0,-45])
238     translate([0,0,jig_main_zsz])
239     rotate([180,0,0])
240     Jig();
241 }
242
243 module PunchHolderT(){ ////toplevel
244   PunchHolder(true);
245 }
246
247 module Demo(){ ////toplevel
248   %PunchHolder();
249   Jig();
250 }
251
252 module Kit(){ ////toplevel
253   JigT();
254   rotate([0,0,-45]){
255     translate([(jig_iters-1)*jig_interval/2,
256                jig_min_y - holder_max_y - 5,
257                0])
258       PunchHolder();
259   }
260 }
261
262 //CrewPunch();
263 //PunchHolder();
264 //PunchHolder(false);
265 //OneJig();
266 //Jig();
267 //Demo();
268 //JigT();
269 //RegistrationProtrusion();
270 //PunchHolderT();
271 //Kit();