omdl  v0.9.8
OpenSCAD Mechanical Design Library
All Files Functions Variables Modules Pages
mounts.scad
Go to the documentation of this file.
1 //! Screw mounts tabs, mount slots, mount posts, etc.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2025
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  \amu_define group_name (Mounts)
31  \amu_define group_brief (Screw mounts tabs, mount slots, mount posts, etc.)
32 
33  \amu_include (include/amu/pgid_path_pstem_pg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group and macros.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/group_in_parent_start.amu)
42  \amu_define includes_required_add
43  (
44  models/3d/fastener/screws.scad
45  )
46  \amu_include (include/amu/includes_required.amu)
47 *******************************************************************************/
48 
49 //----------------------------------------------------------------------------//
50 
51 //! A mount tab with screw hole and support brace.
52 /***************************************************************************//**
53  \param wth <decimal> wall thickness.
54 
55  \param screw <datastruct | decimal> screw bore; structured data or
56  a single decimal to set the bore diameter.
57 
58  \param brace <decimal-list-2 | decimal> brace percentage; a list
59  [by, bz] or a single decimal to set (by=bz).
60 
61  \param size <decimal-list-2 | decimal> tab size; a list [sx, sy].
62 
63  \param vr <decimal-list-4 | decimal> rounding radius; a list
64  [v1r, v2r, v3r, v4r] or a single decimal for
65  (v1r=v2r=v3r=v4r).
66 
67  \param vrm <integer> rounding mode {0|1|2|3|4}.
68 
69  \details
70 
71  Construct a mount tab with a screw hole. The parameters \p wth and
72  \p screw are required (the others are optional). When \p brace is
73  specified, braces are constructed to support and reinforce the
74  connection to the adjacent structure. The brace-to-tab and
75  brace-to-wall lengths can be specified independently. When the \p
76  size if not supplied, a default size will be used based on the
77  specified mount tab features.
78 
79  ## Multi-value and structured parameters
80 
81  ### screw bore
82 
83  #### Data structure fields: screw
84 
85  e | data type | default value | parameter description
86  ---:|:-----------------:|:-----------------:|:------------------------------------
87  0 | <decimal> | required | \p d: bore diameter
88  1 | (see below) | \b undef | \p h: screw head
89  2 | (see below) | \b undef | \p t: tolerance
90 
91  See screw_bore() for documentation of the data types for the
92  screw bore parameters \p h and \p t.
93 
94  \amu_define scope_id (example_mount_screw_tab)
95  \amu_define title (Screw mount tab example)
96  \amu_define image_views (top right diag)
97  \amu_define image_size (sxga)
98 
99  \amu_include (include/amu/scope_diagrams_3d.amu)
100 *******************************************************************************/
101 module mount_screw_tab
102 (
103  wth,
104  screw,
105  brace,
106  size,
107  vr,
108  vrm
109 )
110 {
111  // screw: diameter, head, and tolerance
112  d = defined_e_or(screw, 0, screw);
113  h = defined_e_or(screw, 1, undef);
114  t = defined_e_or(screw, 2, undef);
115 
116  // default size: x and y (adjusted for tolerance and brace thickness)
117  dx = d*3 + defined_e_or(t, 0, 0) + (is_undef(brace) ? 0 : wth*2);
118  dy = d*3 + defined_e_or(t, 1, 0);
119 
120  x = defined_e_or(size, 0, dx);
121  y = defined_e_or(size, 1, dy);
122 
123  // rounding defaults
124  r = defined_or(vr, d/2);
125 
126  rm = vrm == 1 ? [[5,5,0,0], [10,0,9]]
127  : vrm == 2 ? [[5,5,10,9], [10,0,9]]
128  : vrm == 3 ? [[1,1,0,0], [4,0,3]]
129  : vrm == 4 ? [[1,1,4,3], [4,0,3]]
130  : [0, 0];
131 
132  translate([0, y/2, wth/2])
133  union()
134  {
135  // mount tab
136  difference()
137  {
138  extrude_linear_uss(wth, center=true)
139  pg_rectangle([x, y], vr=r, vrm=first(rm), center=true);
140 
141  screw_bore(d=d, l=wth+eps*8, h=h, t=t, a=0);
142  }
143 
144  // mount tab reinforcement triangular brace
145  if ( is_defined(brace) )
146  {
147  by = defined_e_or(brace, 0, brace);
148  bz = defined_e_or(brace, 1, by);
149 
150  sy = y * by /100;
151  sz = y * bz /100;
152 
153  for ( i=[-1, 1] )
154  rotate([0, 90, 0])
155  translate([-wth/2 -sz - eps*2, -y/2, (x/2 - wth/2)*i])
156  extrude_linear_uss(wth, center=true)
157  pg_triangle_sas([sy, 90, sz], vr=r, vrm=second(rm));
158  }
159  }
160 }
161 
162 //! A screw mount slot with optional cover envelope.
163 /***************************************************************************//**
164  \param wth <decimal> wall thickness.
165 
166  \param screw <datastruct> screw bore (see below).
167 
168  \param cover <decimal-length-3 | decimal> cover envelope; a list
169  [co, ct, cb], the cover over and around the top and
170  base, or a single decimal to set (co=ct=cb).
171 
172  \param size <decimal> slot length.
173 
174  \param align <integer-list-3 | integer> mount alignment; a list
175  [ax, ay, az] or a single integer to set ax.
176 
177  \param mode <integer> mode {0=cover, 1=slot (negative), 2=cover
178  with slot removed}.
179 
180  \param f <decimal-list-2 | decimal> scale factor; a list
181  [fd, fh], the bore diameter and bore height scale
182  factors, or a single decimal to specify \p fd only.
183  The default values for both \p fd and \p fh is 1.
184 
185  \details
186 
187  Construct a screw mount slot with an opening that allows for the
188  insertion and interlocking of a screw head. The mount is secured to
189  the screw by sliding the screw head into the mount slot. The mount
190  can be used with and without a cover. The parameter \p size is
191  optional and when not specified, its value is 3 * d (the screw neck
192  diameter).
193 
194  ## Multi-value and structured parameters
195 
196  ### screw bore
197 
198  #### Data structure fields: screw
199 
200  e | data type | default value | parameter description
201  ---:|:-----------------:|:-----------------:|:------------------------------------
202  0 | <decimal> | required | \p d : neck diameter
203  1 | <datastruct> | [d*2, d/2] | \p h : screw head
204 
205  See screw_bore() for documentation of the data types for the
206  screw parameters \p d and \p h.
207 
208  \amu_define scope_id (example_mount_screw_slot)
209  \amu_define title (Screw mount slot example)
210  \amu_define image_views (front top diag)
211  \amu_define image_size (sxga)
212 
213  \amu_include (include/amu/scope_diagrams_3d.amu)
214 *******************************************************************************/
215 module mount_screw_slot
216 (
217  wth,
218  screw,
219  cover,
220  size,
221  align,
222  mode,
223  f
224 )
225 {
226  // slot cover
227  module cover()
228  {
229  // shape overlap adjustment
230  coa = eps*4;
231 
232  hull()
233  for ( x=[-1, 1] )
234  {
235  translate([sl/2*x, 0, sd + cto - coa])
236  cylinder(d=hd + ctt*2 - coa, h=eps);
237 
238  translate([sl/2*x, 0, coa])
239  cylinder(d=hd + ctb*2 - coa, h=eps);
240  }
241  }
242 
243  // slot
244  module slot()
245  {
246  translate([0, 0, -eps*4])
247  union()
248  {
249  // neck slot
250  screw_bore(d, l=sd, h=h, t=[sl], f=f, a=9);
251 
252  // screw insert hole
253  translate([sl/2, 0, 0])
254  cylinder(d=hd, h=sd);
255  }
256  }
257 
258  // diameter and height scale factors
259  fd = defined_eon_or(f, 0, 1);
260  fh = defined_e_or(f, 1, 1);
261 
262  // screw: diameter, head
263  d = defined_e_or(screw, 0, screw);
264  h = defined_e_or(screw, 1, [d*2, d/2]);
265 
266  // local scaled version of screw diameter
267  ld = d * fd;
268 
269  // screw head: diameter, flat height, bevel height
270  hd = defined_e_or(h, 0, 0) * fd;
271  hf = defined_e_or(h, 1, 0) * fh;
272  hb = defined_e_or(h, 2, 0) * fh;
273 
274  // slot cover: default, over, top, bottom
275  cto = defined_eon_or(cover, 0, 0);
276  ctt = defined_e_or(cover, 1, cto);
277  ctb = defined_e_or(cover, 2, ctt);
278 
279  // slot size: depth, length
280  sd = wth + hf;
281  sl = defined_or(size, d * 3);
282 
283  alignments =
284  [
285  [0, -sl-hd-ctt*2, -sl-hd-ctb*2, -sl-hd, -sl, sl, sl+ld, sl+hd, sl+hd+ctb*2, sl+hd+ctt*2]/2,
286  [0, -hd-ctt*2, -hd-ctb*2, -hd, -ld, ld, hd, hd+ctb*2, hd+ctt*2]/2,
287  [0, -wth/2, -wth+hb, -wth, -sd, -sd-cto]
288  ];
289 
290  // when 'align' is scalar assign to 'align_x'
291  align_x = select_ci ( alignments.x, defined_eon_or(align, 0, 0), false );
292  align_y = select_ci ( alignments.y, defined_e_or(align, 1, 0), false );
293  align_z = select_ci ( alignments.z, defined_e_or(align, 2, 0), false );
294 
295  translate([align_x, align_y, align_z])
296  {
297  if (mode == 0)
298  cover();
299 
300  else if (mode == 1)
301  slot();
302 
303  else if (mode == 2)
304  difference()
305  {
306  cover();
307  slot();
308  }
309  }
310 }
311 
312 //! A multi-directional screw mount slot with optional cover envelope.
313 /***************************************************************************//**
314  \param wth <decimal> wall thickness.
315 
316  \param screw <datastruct> screw bore (see below).
317 
318  \param cover <decimal-length-3 | decimal> cover envelope; a list
319  [co, ct, cb], the cover over and around the top and
320  base, or a single decimal to set (co=ct=cb).
321 
322  \param size <decimal> slot length.
323 
324  \param align <integer-list-3 | integer> mount alignment; a list
325  [ax, ay, az] or a single integer to set ax.
326 
327  \param mode <integer> mode {0=cover, 1=slot (negative), 2=cover
328  with slot removed}.
329 
330  \param f <decimal-list-2 | decimal> scale factor; a list
331  [fd, fh], the bore diameter and bore height scale
332  factors, or a single decimal to specify \p fd only.
333  The default values for both \p fd and \p fh is 1.
334 
335  \param slots <datastruct | integer> slot count and separation angle.
336 
337  \details
338 
339  Construct a screw mount slot with an opening that allows for the
340  insertion and interlocking of a screw head. The mount is secured to
341  the screw by sliding the screw head into the mount slot. The mount
342  can be used with and without a cover. The parameter \p size is
343  optional and when not specified, its value is 3 * d (the screw neck
344  diameter).
345 
346  This is a version of mount_screw_slot() that supports multiple
347  slots equally divided around a circle.
348 
349  ## Multi-value and structured parameters
350 
351  ### screw bore
352 
353  #### Data structure fields: screw
354 
355  e | data type | default value | parameter description
356  ---:|:-----------------:|:-----------------:|:------------------------------------
357  0 | <decimal> | required | \p d : neck diameter
358  1 | <datastruct> | [d*2, d/2] | \p h : screw head
359 
360  See screw_bore() for documentation of the data types for the
361  screw parameters \p d and \p h.
362 
363  ### Slot count and separation angle
364 
365  #### Data structure fields: slots
366 
367  e | data type | default value | parameter description
368  ---:|:-----------------:|:-----------------:|:------------------------------------
369  0 | <integer> | required | \p sc : slot count
370  1 | <decimal> | 360/sc | \p sa : slot separation angle
371 
372  \amu_define scope_id (example_mount_screw_slot_md)
373  \amu_define title (Multi-directional screw mount slot example)
374  \amu_define image_views (front top diag)
375  \amu_define image_size (sxga)
376 
377  \amu_include (include/amu/scope_diagrams_3d.amu)
378 *******************************************************************************/
379 module mount_screw_slot_md
380 (
381  wth,
382  screw,
383  cover,
384  size,
385  align,
386  mode,
387  f,
388  slots = 1
389 )
390 {
391  module multi_mss(m=0)
392  {
393  if (sc > 0)
394  for ( i=[0:sc-1] )
395  rotate([0, 0, sa*i])
397  (
398  wth=wth,
399  screw=screw,
400  cover=cover,
401  size=size,
402  align=[4, 0, align_z],
403  mode=m,
404  f=f
405  );
406  }
407 
408  module cover() { multi_mss(0); }
409  module slot() { multi_mss(1); }
410 
411  align_z = defined_eon_or(align, 2, 0);
412 
413  sc = defined_eon_or(slots, 0, 0);
414  sa = defined_e_or(slots, 1, 360/sc);
415 
416  if (mode == 0)
417  cover();
418 
419  if (mode == 1)
420  slot();
421 
422  if (mode == 2)
423  difference()
424  {
425  cover();
426  slot();
427  }
428 }
429 
430 //! A screw mount post with screw bore and optional fins.
431 /***************************************************************************//**
432 
433  \param post <datastruct> post (see below).
434  \param screw <datastruct> screw bore (see below).
435  \param bore_sft <datastruct> self-forming threads screw bore (see below).
436  \param fins <datastruct> fins (see below).
437  \param cut <datastruct> cut (see below).
438 
439  \details
440 
441  Construct a screw mount post with screw bore, fins, and diagonal
442  cut at base. The post and fins have preset rounding configurations,
443  but also support manual rounding specifications. The post screw
444  bore is removed using either screw_bore(), or screw_bore_tsf(), or
445  both. All relevant screw bore features are made available,
446  including nut-slot cut-outs as shown in the examples below. The
447  post can be configured with a diagonally cut base to facilitate 3D
448  printing posts without base support, such as those attached
449  elevated on walls.
450 
451  \note Both \p screw and \p bore_sft may be used together when it is
452  desired to create a recessed screw head and a bore with self
453  forming threads. The \p screw bore diameter will need to be
454  sufficiently reduced so as to not remove the self-forming
455  thread engagement cylinders.
456 
457  ## Multi-value and structured parameters
458 
459  ### post
460 
461  #### Data structure fields: post
462 
463  e | data type | default value | parameter description
464  ---:|:-----------------:|:-----------------:|:------------------------------------
465  0 | <decimal-list-2 \| decimal> | required | \p pd: post diameter(s)
466  1 | <decimal> | required | \p ph: post height
467  2 | <integer-list-4 \| integer \| string> | 0 | rounding mode
468  3 | <decimal-list-4 \| decimal> | min(pd)/8 | rounding radius
469 
470  The post base and top can have different diameters by assigning a
471  list [pdb, pdt]. This is useful for 3D printing unsupported wall
472  attached posts. When \p pd is assigned a decimal the base and top
473  diameters will be equal. The rounding mode can be assigned one of
474  the preset configuration strings: {"p1", ..., "p13"} or assigned
475  a custom value. Both the rounding mode and rounding radius can be
476  assigned a list, to control each edge individually, or a single
477  value when all edges shall be the same.
478 
479  \note When assigning the rounding mode and rounding radius
480  individually, the inner-upper and inner-lower edges of the
481  rectangular revolution, that forms the post, should be
482  assigned zero in most circumstances as follows, for
483  example: [0, 1, 4, 0].
484 
485  ### screw bore
486 
487  #### Data structure fields: screw
488 
489  e | data type | default value | parameter description
490  ---:|:-----------------:|:-----------------:|:------------------------------------
491  0 | <decimal> | required | \p d: bore diameter
492  1 | <decimal> | pd | \p l: bore length
493  2 | <datastruct> | undef | \p h: screw head
494  3 | <datastruct> | undef | \p n: screw nut
495  4 | <datastruct> | undef | \p s: nut slot cutout
496  5 | <datastruct> | undef | \p f: bore scale factor
497 
498  See screw_bore() for documentation of the data types for the
499  screw parameters.
500 
501  ### self-forming threads screw bore
502 
503  #### Data structure fields: bore_sft
504 
505  e | data type | default value | parameter description
506  ---:|:-----------------:|:-----------------:|:------------------------------------
507  0 | <decimal> | required | \p d: bore diameter
508  1 | <decimal> | pd | \p l: bore length
509  2 | <datastruct> | undef | \p t: thread engagement
510 
511  See screw_bore_tsf() for documentation of the data types for the
512  self-forming threads screw bore parameters.
513 
514  ### fins
515 
516  #### Data structure fields: fins
517 
518  e | data type | default value | parameter description
519  ---:|:-----------------:|:-----------------:|:------------------------------------
520  0 | <integer> | required | fin count
521  1 | <integer> | 0 | fin type: {0=triangular, 1=rectangular}
522  2 | <decimal-list-3 \| decimal> | [ph*5/8, pd/4, pd/8] | size scale factors: [h, l, w]
523  3 | <integer-list-n \| integer \| string> | 0 | rounding mode
524  4 | <decimal-list-n \| decimal> | (see below) | rounding radius
525  5 | <decimal> | 360 | distribution angle
526 
527  The rounding mode can be assigned one of the preset configuration
528  strings: {"p1", ..., "p6"} or assigned custom values. Both the
529  rounding mode and rounding radius can be assigned a list, to
530  control each edge individually, or a single value when all edges
531  shall be the same.
532 
533  \note The edge list size is dependent on the fin type; n=3 for
534  triangular, and n=4 for rectangular.
535 
536  ### cut
537 
538  #### Data structure fields: cut
539 
540  e | data type | default value | parameter description
541  ---:|:-----------------:|:-----------------:|:------------------------------------
542  0 | <decimal> | 0 | cut x-angle
543  1 | <decimal> | 0 | cut post base offset
544  2 | <decimal> | 0 | cut z-rotation
545  3 | <decimal> | 4 | cube removal scale
546 
547  The \p cut parameter can be used to cut the base of the post at
548  an angle. As previously discussed, this is useful for 3D-printing
549  wall-attached posts that does not have lower support.
550 
551  \amu_define scope_id (example_mount_screw_post)
552  \amu_define title (Screw mount post example)
553  \amu_define image_views (front top diag)
554  \amu_define image_size (sxga)
555 
556  \amu_include (include/amu/scope_diagrams_3d.amu)
557 *******************************************************************************/
558 module mount_screw_post
559 (
560  post,
561  screw,
562  bore_sft,
563  fins,
564  cut
565 )
566 {
567  // round post fins
568  module round_post_fins(rd, rh)
569  {
570  // move distance for fin to always contact approximated polygon cylinder
571  function fin_embed(r, w) =
572  let
573  (
574  n = get_fn(r),
575  d = polygon_regular_perimeter(n, r) / n
576  )
577  r - sqrt( pow(r,2) - pow(w/2, 2) - pow(d/2, 2) );
578 
579  c = defined_eon_or(fins, 0, 0); // count
580 
581  if ( c > 0 )
582  {
583  t = defined_e_or(fins, 1, 0); // type
584  sf = defined_e_or(fins, 2, undef); // size scale factors: [h, l, t]
585 
586  h = defined_eon_or(sf, 0, 5/8) * rh;
587  l = defined_e_or (sf, 1, 1/4) * rd;
588  w = defined_e_or (sf, 2, 1/8) * rd;
589 
590  d_vr = ( t == 0 ) ? min(h, l)/2 : min(l, w)/2;
591 
592  vrm = defined_e_or(fins, 3, 0); // rounding mode
593  vr = defined_e_or(fins, 4, d_vr); // vertex rounding
594  da = defined_e_or(fins, 5, 360); // distribution angle
595 
596  // triangular
597  if ( t == 0 )
598  {
599  p_vrm =
600  let
601  (
602  p = !is_string(vrm) ? vrm
603  : (vrm == "p1") ? [10, 0, 9]
604  : (vrm == "p2") ? [4, 0, 3]
605  : (vrm == "p3") ? [6, 0, 7]
606  : (vrm == "p4") ? [7, 0, 7]
607  : (vrm == "p5") ? [0, 0, 1]
608  : (vrm == "p6") ? [0, 0, 5]
609  : 0
610  )
611  p;
612 
613  for (i = [0:c-1])
614  {
615  rotate([90, 0, da/c * i + 180])
616  translate([ -rd/2 - l + fin_embed(rd/2, w), 0, 0])
617  extrude_linear_mss(w, center=true)
618  pg_triangle_sas([h, 90, l], vr=vr, vrm=p_vrm);
619  }
620  }
621  else
622 
623  // rectangular
624  if ( t == 1 )
625  {
626  p_vrm =
627  let
628  (
629  p = !is_string(vrm) ? vrm
630  : (vrm == "p1") ? [0, 10, 9, 0]
631  : (vrm == "p2") ? [0, 4, 3, 0]
632  : (vrm == "p3") ? [0, 8, 7, 0]
633  : (vrm == "p4") ? [0, 5, 5, 0]
634  : (vrm == "p5") ? [0, 1, 1, 0]
635  : (vrm == "p6") ? [0, 9, 10, 0]
636  : 0
637  )
638  p;
639 
640  for (i = [0:c-1])
641  {
642  rotate([0, 0, da/c * i])
643  translate([rd/2 + l/2 - fin_embed(rd/2, w), 0, 0])
645  pg_rectangle( [l, w], vr=vr, vrm=p_vrm, center=true);
646  }
647  }
648  }
649  }
650 
651  pd = defined_e_or(post, 0, 0);
652  ph = defined_e_or(post, 1, 0);
653  vrm = defined_e_or(post, 2, 0);
654 
655  pd_min = min( pd );
656  pd_max = max( pd );
657 
658  vr = defined_e_or(post, 3, pd_min/8);
659 
660  p_vrm =
661  let
662  (
663  p = !is_string(vrm) ? vrm
664  : (vrm == "p1" ) ? [0, 5, 10, 0]
665  : (vrm == "p2" ) ? [0, 0, 10, 0]
666  : (vrm == "p3" ) ? [0, 5, 0, 0]
667  : (vrm == "p4" ) ? [0, 1, 0, 0]
668  : (vrm == "p5" ) ? [0, 9, 0, 0]
669  : (vrm == "p6" ) ? [0, 7, 0, 0]
670  : (vrm == "p7" ) ? [0, 1, 4, 0]
671  : (vrm == "p8" ) ? [0, 1, 8, 0]
672  : (vrm == "p9" ) ? [0, 5, 5, 0]
673  : (vrm == "p10") ? [0, 9, 10, 0]
674  : (vrm == "p11") ? [0, 1, 1, 0]
675  : (vrm == "p12") ? [0, 3, 4, 0]
676  : (vrm == "p13") ? [0, 7, 8, 0]
677  : 0
678  )
679  p;
680 
681  //
682  // construct
683  //
684 
685  difference()
686  {
687  union()
688  {
689  // round post
690  rotate_extrude()
691  pg_trapezoid(b=pd/2, h=ph, vr=vr, vrm=p_vrm);
692 
693  // fins
694  if ( is_defined(fins) )
695  round_post_fins(pd_min, ph);
696  }
697 
698  // screw bore
699  if ( is_defined(screw) )
700  {
701  d = defined_eon_or(screw, 0, 0);
702  l = defined_e_or(screw, 1, ph);
703  h = defined_e_or(screw, 2, undef);
704  n = defined_e_or(screw, 3, undef);
705  s = defined_e_or(screw, 4, undef);
706  f = defined_e_or(screw, 5, undef);
707 
708  translate([0, 0, ph+eps*2])
709  screw_bore(d=d, l=l, h=h, n=n, s=s, f=f, a=1);
710  }
711 
712  // self-forming threads screw bore
713  if ( is_defined(bore_sft) )
714  {
715  d = defined_eon_or(bore_sft, 0, 0);
716  l = defined_e_or(bore_sft, 1, ph);
717  t = defined_e_or(bore_sft, 2, undef);
718 
719  translate([0, 0, ph+eps*2])
720  screw_bore_tsf(d=d, l=l, t=t, a=1);
721  }
722 
723  // post cut
724  if ( is_defined(cut) )
725  {
726  a = defined_e_or(cut, 0, 0); // cut x-angle
727  o = defined_e_or(cut, 1, 0); // cut base offset
728  r = defined_e_or(cut, 2, 0); // cut z-rotation
729  s = defined_e_or(cut, 3, 4); // removal scale
730 
731  c = [pd_max, pd_max, ph] * s;
732 
733  translate([0, 0, o])
734  rotate([a, 0, r-90])
735  translate([0, 0, -third(c)/2])
736  cube(c, center=true);
737  }
738  }
739 }
740 
741 //! @}
742 //! @}
743 
744 
745 //----------------------------------------------------------------------------//
746 // openscad-amu auxiliary scripts
747 //----------------------------------------------------------------------------//
748 
749 /*
750 BEGIN_SCOPE example_mount_screw_tab;
751  BEGIN_OPENSCAD;
752  include <omdl-base.scad>;
753  include <models/3d/fastener/screws.scad>;
754  include <parts/3d/enclosure/mounts.scad>;
755 
756  $fn = 36;
757 
758  d = 4;
759  h = [7, 1, 1/2];
760  t = [0, 10];
761 
762  mirror([0,1,0])
763  mount_screw_tab(wth=3, screw=[d, h, t], brace=[50, 25], vrm=4);
764 
765  // end_include
766  END_OPENSCAD;
767 
768  BEGIN_MFSCRIPT;
769  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
770  table_unset_all sizes;
771 
772  images name "sizes" types "sxga";
773  views name "views" views "top right diag";
774 
775  variables set_opts_combine "sizes views";
776  variables add_opts "--viewall --autocenter --view=axes";
777 
778  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
779  END_MFSCRIPT;
780 END_SCOPE;
781 
782 BEGIN_SCOPE example_mount_screw_slot;
783  BEGIN_OPENSCAD;
784  include <omdl-base.scad>;
785  include <models/3d/fastener/screws.scad>;
786  include <parts/3d/enclosure/mounts.scad>;
787 
788  $fn = 36;
789 
790  rotate([0, 90, 90])
791  {
792  w = 2;
793  s = [4, [8, 2, 1]];
794  c = [1, 3, 1];
795 
796  translate([0, -15, 0])
797  mount_screw_slot(wth=w, screw=s, cover=c, mode=1);
798 
799  mount_screw_slot(wth=w, screw=s, cover=c, mode=2);
800 
801  translate([0, +15, 0])
802  difference() {
803  %mount_screw_slot(wth=w, screw=s, cover=c, mode=0);
804  mount_screw_slot(wth=w, screw=s, cover=c, mode=1);
805  }
806  }
807 
808  // end_include
809  END_OPENSCAD;
810 
811  BEGIN_MFSCRIPT;
812  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
813  table_unset_all sizes;
814 
815  images name "sizes" types "sxga";
816  views name "views" views "front top diag";
817 
818  variables set_opts_combine "sizes views";
819  variables add_opts "--viewall --autocenter --view=axes";
820 
821  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
822  END_MFSCRIPT;
823 END_SCOPE;
824 
825 BEGIN_SCOPE example_mount_screw_slot_md;
826  BEGIN_OPENSCAD;
827  include <omdl-base.scad>;
828  include <models/3d/fastener/screws.scad>;
829  include <parts/3d/enclosure/mounts.scad>;
830 
831  $fn = 36;
832 
833  w = 2;
834  s = [4, [8, 2, 1]];
835  c = [1, 3, 1];
836 
837  rotate([-90, 0, 0])
838  mount_screw_slot_md(wth=w, screw=s, cover=c, mode=2, slots=[3, 90]);
839 
840  // end_include
841  END_OPENSCAD;
842 
843  BEGIN_MFSCRIPT;
844  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
845  table_unset_all sizes;
846 
847  images name "sizes" types "sxga";
848  views name "views" views "front top diag";
849 
850  variables set_opts_combine "sizes views";
851  variables add_opts "--viewall --autocenter --view=axes";
852 
853  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
854  END_MFSCRIPT;
855 END_SCOPE;
856 
857 BEGIN_SCOPE example_mount_screw_post;
858  BEGIN_OPENSCAD;
859  include <omdl-base.scad>;
860  include <models/3d/fastener/screws.scad>;
861  include <parts/3d/enclosure/mounts.scad>;
862 
863  $fn = 36;
864 
865  u = undef;
866 
867  translate([-20, 0, 0])
868  mount_screw_post(post=[[10, 5], 4], bore_sft=3, fins=[6, 1, 1]);
869 
870  s = [3, 21, [5, 1, 1, 4], [5, 2, 0, 6, 0, 5], [0, -10]];
871  translate([0, 0, 0])
872  mount_screw_post(post=[10, 20, "p10"], screw=s, fins=[2, 1, 1, "p1"]);
873 
874  translate([+20, 0, 0])
875  mount_screw_post(post=[10, 25, "p1"], screw=[3, 10, [5, 1, 1]], fins=[4, 0, u, "p1"]);
876 
877  // end_include
878  END_OPENSCAD;
879 
880  BEGIN_MFSCRIPT;
881  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
882  table_unset_all sizes;
883 
884  images name "sizes" types "sxga";
885  views name "views" views "front top diag";
886 
887  variables set_opts_combine "sizes views";
888  variables add_opts "--viewall --autocenter --view=axes";
889 
890  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
891  END_MFSCRIPT;
892 END_SCOPE;
893 */
894 
895 //----------------------------------------------------------------------------//
896 // end of file
897 //----------------------------------------------------------------------------//
898 
eps
<decimal> Epsilon, small distance to deal with overlapping shapes.
Definition: constants.scad:195
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 defined_eon_or(v, i, d)
Return the list element or scalar numeric value, if either is defined, otherwise the default value.
function first(v)
Return the first element of an iterable value.
function select_ci(v, i, l=true)
Select specified element from list or return a default.
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_regular_perimeter(n, r, a)
Compute the perimeter of an n-sided regular polygon in 2D.
function get_fn(r)
Return facets number for the given arc radius.
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.
Definition: screws.scad:358
module screw_bore_tsf(d=1, l=1, t, a)
Gapped fastener bore with engagement cylinders for self-forming threads.
Definition: screws.scad:695
module mount_screw_post(post, screw, bore_sft, fins, cut)
A screw mount post with screw bore and optional fins.
Definition: mounts.scad:1281
module mount_screw_slot(wth, screw, cover, size, align, mode, f)
A screw mount slot with optional cover envelope.
Definition: mounts.scad:630
module mount_screw_slot_md(wth, screw, cover, size, align, mode, f, slots=1)
A multi-directional screw mount slot with optional cover envelope.
Definition: mounts.scad:948
module mount_screw_tab(wth, screw, brace, size, vr, vrm)
A mount tab with screw hole and support brace.
Definition: mounts.scad:362
module pg_trapezoid(b=1, h, l=1, a=90, o=origin2d, vr, vrm=1, vfn, center=false)
A polygon trapezoid with individual vertex rounding and arc facets.
Definition: polygon.scad:716
module pg_triangle_sas(v, a=x_axis_ci, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by size-angle-size with vertex rounding.
Definition: polygon.scad:1104
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.
Definition: polygon.scad:765
module extrude_linear_mss(h, center=false, c=true)
Linearly extrude a 2d shape with multi-segment uniformly-spaced profile scaling.
Definition: extrude.scad:748
module extrude_linear_uss(h, center=false, c=true, ha=0)
Linearly extrude a 2d shape with uniformly-spaced profile scaling.
Definition: extrude.scad:666