omdl  v1.0
OpenSCAD Mechanical Design Library
enclosure_stand_rectangle.scad
Go to the documentation of this file.
1 //! A stand maker for rectangular prism project boxes, housings, and enclosures.
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 (Rectangular Enclosure Stand)
31  \amu_define group_brief (Stand maker for rectangular prism enclosures.)
32 
33  \amu_include (include/amu/doxyg_init_pd_gds_ipg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group and macros.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/doxyg_define_in_parent_open.amu)
42  \amu_include (include/amu/includes_required.amu)
43 *******************************************************************************/
44 
45 //----------------------------------------------------------------------------//
46 
47 //! A stand maker for rectangular project boxes, housings, and enclosures.
48 /***************************************************************************//**
49  \param size <decimal-list-3 | decimal> dimension(s); a list
50  [w, d, h], the width, depth, and height, or a single
51  decimal for width.
52 
53  \param offset <decimal> the case seat vertical offset.
54 
55  \param brace <decimal> the stand brace member percentage of
56  (seat + offset).
57 
58  \param count <integer> the number of enclosures.
59 
60  \param space <decimal> the additional separation space between
61  multiple enclosures.
62 
63  \param form <integer> the stand form {0 : 7}. Form 6 and 7 can be
64  used as a top brace, or stacking stop brace, for a
65  multi-enclosure stand.
66 
67  \param mode <integer> the size specification mode
68  {0: size of case, 1: size of stand}.
69 
70  \details
71 
72  Construct a stand for a rectangular prism enclosure. A
73  multi-enclosure stand can be constructed using the \p count
74  parameter. The size can refer to the enclosure size or the stand
75  size as controlled by the \p mode parameter. The \p form = 6 is
76  useful for creating top braces for multi-enclosure stands.
77 
78  \amu_define scope_id (example)
79  \amu_define title (Muilti-enclosure example)
80  \amu_define image_views (right front diag)
81  \amu_define image_size (sxga)
82 
83  \amu_include (include/amu/scope_diagrams_3d.amu)
84 *******************************************************************************/
86 (
87  size,
88 
89  offset = 0,
90  brace = 1/2,
91 
92  count = 1,
93  space = 0,
94 
95  form = 0,
96  mode = 0
97 )
98 {
99  // decode size
100  size_w = defined_e_or(size, 0, size);
101  size_d = defined_e_or(size, 1, (mode == 0) ? size_w*6 : size_w);
102  size_h = defined_e_or(size, 2, (mode == 0) ? size_w*7 : size_w);
103 
104  // size specification mode: 0=case, 1=stand
105  width = (mode == 0) ? size_w : size_w;
106  depth = (mode == 0) ? size_d/6 : size_d;
107  height = (mode == 0) ? size_h/7 : size_h;
108 
109  // stand end section profile size
110  standx = width*3/4;
111  standy = height;
112 
113  // curve transition
114  curvex = standy*4/25;
115  curvey = standy/4;
116 
117  // seat width and feature thickness
118  seatx = standx/8;
119  seaty = standy/4;
120 
121  // stand end upper thickness
122  wall = (standx + standy)/12;
123 
124  // polygon form set 0
125  pg_fs0 =
126  let
127  (
128  x1 = 0,
129  x2 = seatx,
130  x3 = seatx + wall,
131  x4 = x3 + curvex,
132  x5 = seatx + standx,
133 
134  x6 = seatx + wall + space,
135  x7 = x6 + seatx,
136 
137  y1 = 0,
138  y2 = seaty + offset,
139  y3 = standy + offset,
140  y4 = curvey,
141  y5 = wall,
142 
143  r = wall
144  )
145  [
146  [ // center section (same for all)
147  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x6, y3], [x6, y2], [x7, y2], [x7, y1]],
148  [r/10, 0, r/5, r/5, 0, r/10, r*2/5, r*2/5],
149  [1, 0, 1, 1, 0, 1, 1, 1]
150  ],
151  [ // end section (original curved)
152  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x4, y4], [x5, y5], [x5, y1]],
153  [r/10, 0, r/5, r*3/5, r*4/5, r, r/5, r*2/5],
154  [1, 0, 1, 1, 1, 1, 1, 1]
155  ],
156  [ // end section (original beveled)
157  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x4, y4], [x5, y5], [x5, y1]],
158  [r/10, 0, r/5, r*3/5, r, r, r/5, r*2/5],
159  [1, 0, 1, 1, 5, 1, 1, 1]
160  ],
161  [ // end section (rectangular rounded)
162  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x3, y5], [x5, y5], [x5, y1]],
163  [r/10, 0, r/5, r*3/5, r, r, r/5, r*2/5],
164  [1, 0, 1, 1, 1, 1, 1, 1]
165  ],
166  [ // end section (rectangular beveled small)
167  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x3, y5], [x5, y5], [x5, y1]],
168  [r/10, 0, r/5, r*3/5, r, r, r/5, r*2/5],
169  [1, 0, 1, 1, 5, 1, 1, 1]
170  ],
171  [ // end section (rectangular beveled large)
172  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x3, y5], [x5, y5], [x5, y1]],
173  [r/10, 0, r/5, r*3/5, r*2, r, r/5, r*2/5],
174  [1, 0, 1, 1, 5, 1, 1, 1]
175  ],
176  [ // end section (original, triangular)
177  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x3, y3], [x5, y5], [x5, y1]],
178  [r/10, 0, r/5, r*3/5, r, r/5, r*2/5],
179  [1, 0, 1, 1, 1, 1, 1]
180  ],
181  [ // center section (dual side)
182  [[x1, y1], [x1, y2], [x2, y2], [x2, y3], [x6, y3], [x6, y2], [x7, y2], [x7, y1],
183  [x6, y1], [x6, y2-y3], [x2, y2-y3], [x2, y1]],
184  [r/5, 0, r/5, r/5, 0, r/5, r/5, 0, r/5,
185  r/5, 0, r/5, r/5],
186  [1, 0, 1, 1, 0, 1, 1, 0,
187  1, 1, 0, 1]
188  ]
189  ];
190 
191  // select polygon forms (default = first)
192  pg_f =
193  select_ci
194  ( [
195  [ pg_fs0[1], pg_fs0[0] ],
196  [ pg_fs0[2], pg_fs0[0] ],
197  [ pg_fs0[3], pg_fs0[0] ],
198  [ pg_fs0[4], pg_fs0[0] ],
199  [ pg_fs0[5], pg_fs0[0] ],
200  [ pg_fs0[6], pg_fs0[0] ],
201  [ pg_fs0[0], pg_fs0[0] ],
202  [ pg_fs0[7], pg_fs0[7] ]
203  ], form, false
204  );
205 
206  pg_fe = first( pg_f );
207  pg_fc = second( pg_f );
208 
209  // round polygons
210  pg_end = polygon_round_eve_all_p( c=first(pg_fe), vr=second(pg_fe), vrm=third(pg_fe) );
211  pg_cnt = polygon_round_eve_all_p( c=first(pg_fc), vr=second(pg_fc), vrm=third(pg_fc) );
212 
213  //
214  // construct stand
215  //
216 
217  linear_extrude(depth)
218  union()
219  {
220  span = width + wall + space;
221  oset = seatx + wall/2 + space/2;
222 
223  // center section(s)
224  for (x = [0:count-2])
225  translate([ span*x - span*(count-2)/2 - oset, 0])
226  polygon( pg_cnt );
227 
228  // section tie(s)
229  for (x=[0:count-1])
230  translate([ span*x - span*(count-1)/2, (seaty+offset)/2])
231  square([width, (seaty+offset)*brace], center=true);
232 
233  // end sections
234  for (x = [0, 1])
235  mirror([x, 0, 0])
236  translate([ span*count/2 - oset, 0])
237  polygon( pg_end );
238  }
239 }
240 
241 //! @}
242 //! @}
243 
244 
245 //----------------------------------------------------------------------------//
246 // openscad-amu auxiliary scripts
247 //----------------------------------------------------------------------------//
248 
249 /*
250 BEGIN_SCOPE example;
251  BEGIN_OPENSCAD;
252  include <omdl-base.scad>;
253  include <parts/3d/enclosure/enclosure_stand_rectangle.scad>;
254 
255  rotate([90, 0, 0])
256  {
257  e = [35, 125, 125]; w = first(e);
258  c = 3; o = 8 + 3/4; s = 2 + 17/32;
259 
260  translate([0, 0, -w/2 + w])
261  enclosure_stand_rectangle( size=w, count=c );
262 
263  translate([0, 0, -w/2 - w])
264  enclosure_stand_rectangle( size=w, count=c );
265 
266  translate([0, third(e)+o*2, -w/2])
267  mirror([0, 1, 0])
268  enclosure_stand_rectangle( size=w, count=c, form=6 );
269 
270  %for (x = [-1, 0, +1])
271  translate([(w+s*2)*x, second(e)/2+o, 0])
272  cube(e, center=true);
273  }
274 
275  // end_include
276  END_OPENSCAD;
277 
278  BEGIN_MFSCRIPT;
279  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
280  table_unset_all sizes;
281 
282  images name "sizes" types "sxga";
283  views name "views" views "right front diag";
284 
285  variables set_opts_combine "sizes views";
286  variables add_opts "--viewall --autocenter --view=axes";
287 
288  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
289  END_MFSCRIPT;
290 END_SCOPE;
291 */
292 
293 //----------------------------------------------------------------------------//
294 // end of file
295 //----------------------------------------------------------------------------//
296 
function defined_e_or(v, i, d)
Returns an element from an iterable if it exists, or a default value if not.
function third(v)
Return the third element of an iterable value.
function count(mv, v, s=true, i)
Count all occurrences of a match value in 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 select_ci(v, i, l=true)
Select specified element from list or return a default.
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 enclosure_stand_rectangle(size, offset=0, brace=1/2, count=1, space=0, form=0, mode=0)
A stand maker for rectangular project boxes, housings, and enclosures.