135 module construct_latch()
142 module construct_catch()
147 offset(r=catch_g+catch_h) polygon(latch_p);
148 offset(r=catch_g) polygon(catch_p);
151 throat_w = hprofile_p[1].x*2;
153 translate([0, -catch_h/2])
154 square([ throat_w + catch_g*2 + catch_h*2, catch_h + catch_g*2], center = true);
159 module construct_mount(n, t)
168 pg_rectangle(size=[size_my, size_mz], vr=pad_vr, center=true);
172 translate([p*mnt_dx/2, pad_dy/2 - size_mz/2, 0])
174 pg_rectangle(size=[pad_dx, pad_dy], vr=mnt_vr, center=true);
179 translate([s*mnt_dx/2, pad_dy/2 - size_mz/2, 0])
180 screw_bore(d=screw_d, l=size_my+
eps*8, h=[screw_h, screw_r, screw_b], t=[screw_t]);
186 ([ n,
" mount, type ", t,
": screw hole diameter = ",
187 screw_d,
", offset = ", mnt_dx
210 translate([0, -size_my/2, size_mz/2])
213 construct_mount("latch", latch_t);
216 translate([0, -size_my/4+
eps*2, size_mz/2])
218 pg_rectangle(size=[width_t*2, size_my/2], vr=2, vrm=[0, 0, 4, 3], center=true);
225 translate([0, -size_mz/2, size_my/2])
228 construct_mount("latch", latch_t);
231 rotate([270, 270, 270])
255 translate([0, size_my/2 + size_py + catch_g + catch_h*0, size_mz/2])
257 construct_mount("catch", catch_t);
266 translate([0, -size_mz/8 + size_py + catch_g + catch_h, size_my/2])
267 construct_mount("catch", catch_t);
269 resize([size_px+catch_g*4, size_py+catch_g*4, size_pz])
316 width_t =
defined_e_or(prof_w, 0, 60) / 100 * size_px/2;
317 width_c =
defined_e_or(prof_w, 1, 100) / 100 * size_px/2;
318 width_h =
defined_e_or(prof_w, 2, 10) / 100 * size_px/2;
330 mnt_dx = size_mx - size_mz;
332 pad_dy = max(screw_d*3, size_mz);
333 pad_dx = pad_dy + screw_t;
342 [width_t, 0], [width_t, length_t],
343 [width_c, length_s], [width_c, length_e],
347 hprofile_vr = [1/3, 1/2, 1, 1, 1/10] * size_px/2;
348 hprofile_vrm = [0, 1, 1, 1, 1];
351 profile_p = concat( [for (i=hprofile_p) i], [for (i=
reverse(hprofile_p)) [-i.x, i.y]] );
352 profile_vr = concat( [for (i=hprofile_vr) i], [for (i=
reverse(hprofile_vr)) i] );
353 latch_vrm = concat( [for (i=hprofile_vrm) i], [for (i=
reverse(hprofile_vrm)) i] );
356 catch_vrm = concat(
headn(concat( [3],
tailn(latch_vrm))), [4] );
364 let( h1 = bevel_f, h2 = bevel_v, s = 1 - bevel_h )
365 [ [h1, [s, s]], [h2, [s, 1]], size_pz - (h1 + h2)*2, [h2, [1, s]], [h1, [s, s]] ];
373 tl = latch_t, tc = catch_t,
376 v01 = catch_g+catch_h,
377 v02 = +size_mz/8-size_py-v01,
379 c01 = [ [0,0,0], [0,0,0], [ [0],[0],[0] ] ],
380 c02 = [0, +mnt_dx/2+pad_dx/2, +mnt_dx/2, -mnt_dx/2, -mnt_dx/2-pad_dx/2],
381 c03 = [0, -size_pz/2, -size_pz, -pad_dy/2, -pad_dy],
382 c04 = [0, -size_my/2, -size_my, -size_pz/2, -size_pz]
386 (tl == 1) ? [ [0, 0, 0], [0, 0, 0],
387 [ [0, -width_t, +width_t],
388 [0, -size_py/2, -size_py],
389 [0, -size_pz/2, -size_pz] ] ]
390 : (tl == 2) ? [ [0, 0, 0], [0, +size_my, 0],
392 [0, -size_my, -size_py/2-size_my, -size_py-size_my],
394 : (tl == 3) ? [ [0, 0, 0], [0, +pad_dy, 0],
396 [0, -pad_dy/2, -pad_dy, -size_py/2-pad_dy, -size_py-pad_dy],
402 (tc == 1) ? [ [0, 0, 180], [0, +size_py+v01, 0],
403 [ [0, +size_px/2+v01, -size_px/2-v01],
404 [0, -catch_h, -size_py/2-catch_h, -size_py-catch_h],
405 [0, -size_pz/2, -size_pz] ] ]
406 : (tc == 2) ? [ [0, 0, 180], [0, +size_py+catch_g+size_my, 0],
408 [0, -size_my, -size_py/2-size_my-catch_g, -size_py-size_my],
410 : (tc == 3) ? [ [0, 0, 180], [0, pad_dy/2-v02, 0],
412 [0, -pad_dy/2, -pad_dy, v02-pad_dy/2+size_py/2, v02-pad_dy/2],
418 [ [0, 0, 0], [0, 0, 0],
421 -size_py/2, +v02/2+pad_dy/4,
422 -size_py-catch_g, +size_my, -size_py-catch_g-size_my,
423 +pad_dy, +pad_dy/2, +v02+pad_dy/2, +v02, +v02-pad_dy/2
425 concat(c03, [-size_my]) ]
438 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, a)
Flat and beveled-head fastener bore with nut, nut slot, and bore tolerance.
module catch_latch(size=5, screw, latch, catch, profile, align, verb=0)
A catch latch generator with configurable profile.
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.