119 module construct_latch()
126 module construct_catch()
131 offset(r=catch_g+catch_h) polygon(latch_p);
132 offset(r=catch_g) polygon(catch_p);
135 throat_w = hprofile_p[1].x*2;
137 translate([0, -catch_h/2])
138 square([ throat_w + catch_g*2 + catch_h*2, catch_h + catch_g*2], center = true);
143 module construct_mount(n, t)
152 pg_rectangle(size=[size_my, size_mz], vr=pad_vr, center=true);
156 translate([p*mnt_dx/2, pad_dy/2 - size_mz/2, 0])
158 pg_rectangle(size=[pad_dx, pad_dy], vr=mnt_vr, center=true);
163 translate([s*mnt_dx/2, pad_dy/2 - size_mz/2, 0])
164 screw_bore(d=screw_d, l=size_my+
eps*8, h=[screw_h, screw_r, screw_b], t=[screw_t]);
170 ([ n,
" mount, type ", t,
": screw hole diameter = ",
171 screw_d,
", offset = ", mnt_dx
194 translate([0, -size_my/2, size_mz/2])
197 construct_mount("latch", latch_t);
200 translate([0, -size_my/4+
eps*2, size_mz/2])
202 pg_rectangle(size=[width_t*2, size_my/2], vr=2, vrm=[0, 0, 4, 3], center=true);
209 translate([0, -size_mz/2, size_my/2])
212 construct_mount("latch", latch_t);
215 rotate([270, 270, 270])
239 translate([0, size_my/2 + size_py + catch_g + catch_h*0, size_mz/2])
241 construct_mount("catch", catch_t);
250 translate([0, -size_mz/8 + size_py + catch_g + catch_h, size_my/2])
251 construct_mount("catch", catch_t);
253 resize([size_px+catch_g*4, size_py+catch_g*4, size_pz])
295 width_t =
defined_e_or(p_width, 0, 60) / 100 * size_px/2;
296 width_c =
defined_e_or(p_width, 1, 100) / 100 * size_px/2;
297 width_h =
defined_e_or(p_width, 2, 10) / 100 * size_px/2;
300 height_t =
defined_e_or(p_height, 0, 20) / 100 * size_py;
301 height_s =
defined_e_or(p_height, 1, 40) / 100 * size_py;
302 height_e =
defined_e_or(p_height, 2, 60) / 100 * size_py;
309 mnt_dx = size_mx - size_mz;
311 pad_dy = max(screw_d*3, size_mz);
312 pad_dx = pad_dy + screw_t;
321 [width_t, 0], [width_t, height_t],
322 [width_c, height_s], [width_c, height_e],
326 hprofile_vr = [1/3, 1/2, 1, 1, 1/10] * size_px/2;
327 hprofile_vrm = [0, 1, 1, 1, 1];
330 profile_p = concat( [for (i=hprofile_p) i], [for (i=
reverse(hprofile_p)) [-i.x, i.y]] );
331 profile_vr = concat( [for (i=hprofile_vr) i], [for (i=
reverse(hprofile_vr)) i] );
332 latch_vrm = concat( [for (i=hprofile_vrm) i], [for (i=
reverse(hprofile_vrm)) i] );
335 catch_vrm = concat(
headn(concat( [3],
tailn(latch_vrm))), [4] );
343 let( h1 = bevel_f, h2 = bevel_v, s = 1 - bevel_h )
344 [ [h1, [s, s]], [h2, [s, 1]], size_pz - (h1 + h2)*2, [h2, [1, s]], [h1, [s, s]] ];
352 tl = latch_t, tc = catch_t,
355 v01 = catch_g+catch_h,
356 v02 = +size_mz/8-size_py-v01,
358 c01 = [ [0,0,0], [0,0,0], [ [0],[0],[0] ] ],
359 c02 = [0, +mnt_dx/2+pad_dx/2, +mnt_dx/2, -mnt_dx/2, -mnt_dx/2-pad_dx/2],
360 c03 = [0, -size_pz/2, -size_pz, -pad_dy/2, -pad_dy],
361 c04 = [0, -size_my/2, -size_my, -size_pz/2, -size_pz]
365 (tl == 1) ? [ [0, 0, 0], [0, 0, 0],
366 [ [0, -width_t, +width_t],
367 [0, -size_py/2, -size_py],
368 [0, -size_pz/2, -size_pz] ] ]
369 : (tl == 2) ? [ [0, 0, 0], [0, +size_my, 0],
371 [0, -size_my, -size_py/2-size_my, -size_py-size_my],
373 : (tl == 3) ? [ [0, 0, 0], [0, +pad_dy, 0],
375 [0, -pad_dy/2, -pad_dy, -size_py/2-pad_dy, -size_py-pad_dy],
381 (tc == 1) ? [ [0, 0, 180], [0, +size_py+v01, 0],
382 [ [0, +size_px/2+v01, -size_px/2-v01],
383 [0, -catch_h, -size_py/2-catch_h, -size_py-catch_h],
384 [0, -size_pz/2, -size_pz] ] ]
385 : (tc == 2) ? [ [0, 0, 180], [0, +size_py+catch_g+size_my, 0],
387 [0, -size_my, -size_py/2-size_my-catch_g, -size_py-size_my],
389 : (tc == 3) ? [ [0, 0, 180], [0, pad_dy/2-v02, 0],
391 [0, -pad_dy/2, -pad_dy, v02-pad_dy/2+size_py/2, v02-pad_dy/2],
397 [ [0, 0, 0], [0, 0, 0],
400 -size_py/2, +v02/2+pad_dy/4,
401 -size_py-catch_g, +size_my, -size_py-catch_g-size_my,
402 +pad_dy, +pad_dy/2, +v02+pad_dy/2, +v02, +v02-pad_dy/2
404 concat(c03, [-size_my]) ]
417 translate(
second(oaa) + [align_x, align_y, align_z])
origin2d
<point-2d> The origin point coordinate in 2d Euclidean space.
eps
<decimal> Epsilon, small distance to deal with overlapping shapes.
grid_coarse
OpenSCAD coarse grid limit.
function headn(v, n=1)
Return a list containing all but the last n elements of an iterable value.
function defined_e_or(v, i, d)
Return an element of an iterable when it exists or a default value otherwise.
function third(v)
Return the third element of an iterable value.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function tailn(v, n=1)
Return a list containing all but the first n elements of an iterable value.
function reverse(v)
Reverse the elements of an iterable value.
function select_ci(v, i, l=true)
Select specified element from list or return a default.
function strl(v)
Convert a list of values to a concatenated string.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
function is_defined(v)
Test if a value is defined.
function polygon_round_eve_all_p(c, vr=0, vrm=1, vfn, w=true, cw=true)
Compute coordinates that round all of the vertices between each adjacent edges in 2D.
module screw_bore(d=1, l=1, h, n, t, s, f=1, a=0)
Flat and beveled-head screw bore with nut, nut slot, and bore tolerance.
module catch_latch(size=5, screw, latch, catch, p_bevel, p_width, p_height, align, verb=0)
A catch latch generator.
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.