-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpanel-tnut-notched.scad
482 lines (419 loc) · 18 KB
/
panel-tnut-notched.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
//
// PANEL-TNUT-NOTCHED
// by ISC 2021-09
//
// TNutCageNotched_M( targetWidth, notches, tnutProfile, notchProfile ) - draw 2D t-nut capture with notches
// TNutCageNotched_F( targetWidth, notches, tnutProfile, notchProfile ) - draw 2D t-nut capture with notches
// TNutCageNotched( targetWidth, notches, tnutProfile, notchProfile ) - draw 2D t-nut capture with notches
//
include <KVTree.scad>
include <panel-notch.scad>
include <panel-tnut.scad>
//
// DEMO
//
// run me !!!
//TNutCageNotched_Demo();
//TNutCageNotched_Assembly_Demo();
module TNutCageNotched_Demo() {
include <nuts-bolts.scad>
include <orientation.scad>
$fn = 20;
panelThickness = 3;
// NOTCH PROFILE
notchProfile = NotchProfile(
panelThickness = panelThickness,
notchWidthAllowance = 0, holeWidthAllowance = 1,
notchHeightAllowance = 0, holeHeightAllowance = 1
);
// T-NUT PROFILE
boltProfile = BoltProfile(
shaftDiameter = 3,
length = 15,
headDiameter = 5,
headThickness = 3 );
nutProfile = NutProfile(
boltDiameter = 3,
nutDiameter = 5,
thickness = 3 );
tnutProfile = TNutCageProfile(
connectedPanelThickness = panelThickness,
boltProfile = boltProfile,
nutProfile = nutProfile,
nutEdgeGap = 8, // panel edge to captured nut
boltDiameterAllowance = 1, // allowance from physical sizes
boltLengthAllowance = 0.5,
nutDiameterAllowance = 1,
nutThicknessAllowance = 1
);
// ...possibly extract from another module
edgeGap =kvGet(tnutProfile,"nut.edgeGap");
nutThickness=kvGet(tnutProfile,"nut.thickness");
// *** SINGLE T-NUT ***
translate([0,0,0]) {
OFFront(panelThickness,panelThickness) color( "lightgray" ) {
OBottom(panelThickness)
Bolt(boltProfile);
OBottom(panelThickness,edgeGap+panelThickness+nutThickness) rotate([0,0,30])
Nut(nutProfile);
}
malePanel(30,notchProfile)
/* ▶ */ TNutCageNotched_M( 30, 0, tnutProfile, notchProfile );
OBack(panelThickness) femalePanel(30)
/* ▶ */ TNutCageNotched_F( 30, 0, tnutProfile, notchProfile );
}
// *** MULTIPLE T-NUTS 1 ***
translate([60,0,0]) rotate([0,0,180]) {
OFFront(panelThickness,panelThickness) color( "lightgray" ) {
notchRepeaterOutside(50,1) {
OBottom(panelThickness)
Bolt(boltProfile);
OBottom(panelThickness,edgeGap+panelThickness+nutThickness) rotate([0,0,30])
Nut(nutProfile);
}
}
malePanel(50,notchProfile)
/* ▶ */ TNutCageNotched( 50, 1, tnutProfile, notchProfile );
OBack(panelThickness) femalePanel(50)
/* ▶ */ TNutCageNotched( 50, -1, tnutProfile, notchProfile );
}
// *** MULTIPLE T-NUTS 2 ***
translate([150,0,0]) {
OFFront(panelThickness,panelThickness) color( "lightgray" ) {
notchRepeaterOutside(80,3) {
OBottom(panelThickness)
Bolt(boltProfile);
OBottom(panelThickness,edgeGap+panelThickness+nutThickness) rotate([0,0,30])
Nut(nutProfile);
}
}
malePanel(80,notchProfile)
/* ▶ */ TNutCageNotched( 80, 3, tnutProfile, notchProfile );
OBack(panelThickness) femalePanel(80)
/* ▶ */ TNutCageNotched( 80, -3, tnutProfile, notchProfile );
}
module malePanel(width,notchProfile) {
linear_extrude(panelThickness,center=true)
difference() {
union() {
translate([0,-10,0]) square([width,20],center=true); // panel top at origin
nHa=kvGet(notchProfile,"notch.heightAllowance");
if (nHa>0) // notchHeightAllowance above origin
translate([0,nHa/2-0.5,0]) square([width,nHa+1],center=true);
}
children();
}
}
module femalePanel(width) {
color( "green", 0.7 )
linear_extrude(panelThickness,center=true)
difference() {
square([width,20],center=true);
children();
}
}
}
module TNutCageNotched_Assembly_Demo() {
include <nuts-bolts.scad>
include <positioning.scad>
include <orientation.scad>
$fn=20;
W = 80; // width
D = 50; // depth
H = 100; // height
T = 3; // panel thickness
S1 = 10; // shelf1 position (from bottom)
S2 = 50; // shelf2 position (from bottom)
SF1 = S1+T/2; // shelf1 front panel height
SF2 = H-S2+T/2; // shelf2 front panel height
EXT = 5; // extension to place bolts
// NOTCH PROFILE
notchProfile = NotchProfile(
panelThickness = T,
notchWidthAllowance = 0, holeWidthAllowance = 1,
notchHeightAllowance = 0, holeHeightAllowance = 1
);
// T-NUT PROFILE
boltProfile = BoltProfile(
shaftDiameter = 1,
length = 8,
headDiameter = 3,
headThickness = 1 );
nutProfile = NutProfile(
boltDiameter = 1,
nutDiameter = 3,
thickness = 1 );
tnutProfile = TNutCageProfile(
connectedPanelThickness = T,
boltProfile = boltProfile,
nutProfile = nutProfile,
nutEdgeGap = 3, // panel edge to captured nut
boltDiameterAllowance = 1, // allowance from physical sizes...
boltLengthAllowance = 0.5,
nutDiameterAllowance = 1,
nutThicknessAllowance = 1
);
// ...possibly extract from another module
edgeGap =kvGet(tnutProfile,"nut.edgeGap");
nutThickness=kvGet(tnutProfile,"nut.thickness");
assembly();
translate([120,0,0])
rotate([0,0,180])
assembly();
showBolts=true;
module assembly() {
CubeExtents(W,D,H);
// shelves
color("LightGrey") OBottom (0,H/2-S1) solid() shelfBottom();
color("LightGrey") OBottom (0,H/2-S2) solid() shelfBottom();
if (showBolts) OFBottom(0,H/2-S1) shelfBottomBolts();
if (showBolts) OBottom (0,H/2-S2) shelfBottomBolts();
// walls
OLeft (T,W/2) solid() walls();
ORight (T,W/2) solid() rotate([0,180,0]) walls();
if (showBolts) OLeft (T,W/2) wallBolts();
if (showBolts) OFRight(T,W/2) mirror([0,0,1]) wallBolts();
// shelves front panel
color("gray") OFront(T,D/2,0,-H/2+SF1/2) solid() frontPanel1();
color("gray") OFront(T,D/2,0, H/2-SF2/2) solid() frontPanel2();
if (showBolts) OFront(T,D/2,0,-H/2+SF1/2) frontPanel1Bolts();
if (showBolts) OFront(T,D/2,0, H/2-SF2/2) frontPanel2Bolts();
// back panel
color("DarkGray") OBack(T,D/2) solid() back();
if (showBolts) OBack(T,D/2) backBolts();
}
module solid() linear_extrude(T,center=true) children();
module boltNut() {
color("SandyBrown") {
translate([0,0,T/2]) Bolt(boltProfile);
translate([0,0,-T/2-nutThickness-edgeGap]) Nut(nutProfile);
}
}
// *** WALLS ***
module walls() {
right = +EXT;
effD = D+right;
punch() {
MRight(right/2)
square([effD,H],center=true);
union() {
MUp(S1) PBottom(H) TNutCageNotched(D,-2,tnutProfile,notchProfile,5,5); // holes for shelf bottom
MUp(S2) PBottom(H) TNutCageNotched(D,-2,tnutProfile,notchProfile,5,5);
MLeft(T/2) PRight(D) TNutCageNotched(H,-3,tnutProfile,notchProfile); // back panel
// shelves front panel
MUp (H/2-SF2/2) PLeft(D) TNutCageNotched_M(SF2,2,tnutProfile,notchProfile,5,5);
// for bottom, single t-nut, trim panel
MDown(H/2-SF1/2,T) PLeft(D) TNutCage_M(tnutProfile);
MDown(H/2-SF1/2,T/2) PLeft(D) square([SF1,T],center=true);
}
}
}
module wallBolts() {
// those with negative (-) count in walls() are holes, plug with bolts
// while testing, show only:
// - wallBolts();
// - solid() walls();
MUp(S1) PBottom(H) notchRepeaterOutside(D-5-5,2) boltNut();
MUp(S2) PBottom(H) notchRepeaterOutside(D-5-5,2) boltNut();
MLeft(T/2) PRight(D) notchRepeaterOutside(H,3) boltNut();
}
// *** BACK ***
module back() {
punch() {
square([W,H],center=true);
union() {
PLeft(W) TNutCageNotched(H, 3,tnutProfile,notchProfile); // walls
PRight(W) TNutCageNotched(H, 3,tnutProfile,notchProfile);
MUp(S1) PBottom(H) TNutCageNotched(W,-2,tnutProfile,notchProfile,10,10); // shelves bottom
MUp(S2) PBottom(H) TNutCageNotched(W,-2,tnutProfile,notchProfile,10,10);
}
}
}
module backBolts() {
MUp(S1) PBottom(H) notchRepeaterOutside(W-10-10,2) boltNut();
MUp(S2) PBottom(H) notchRepeaterOutside(W-10-10,2) boltNut();
}
// *** SHELVES BOTTOM ***
module shelfBottom() {
bottom = +EXT;
effD = D+bottom;
punch() {
MDown(bottom/2)
square([W,effD],center=true);
union() {
PLeft(W) TNutCageNotched(D, 2,tnutProfile,notchProfile,5,5); // walls
PRight(W) TNutCageNotched(D, 2,tnutProfile,notchProfile,5,5);
MUp(T/2) PBottom(D) TNutCageNotched(W,-2,tnutProfile,notchProfile); // front
PTop(D) TNutCageNotched(W, 2,tnutProfile,notchProfile,10,10); // back
}
}
}
module shelfBottomBolts() {
bottom = +EXT;
MUp(bottom-T) PBottom(D) notchRepeaterOutside(W,2) boltNut();
}
// *** SHELVES FRONT ***
module frontPanel1() {
effW=W+EXT*2;
punch() {
square([effW,SF1],center=true);
union() {
MRight(T/2) PLeft(W) TNutCage_F (tnutProfile); // walls
MLeft (T/2) PRight(W) TNutCage_F (tnutProfile);
PTop(SF1) TNutCageNotched (W,2,tnutProfile,notchProfile); // front
}
}
}
module frontPanel1Bolts() {
top =-T;
MRight(T/2) PLeft( W) notchRepeaterOutside(SF1,0) boltNut();
MLeft (T/2) PLeft(-W) notchRepeaterOutside(SF1,0) boltNut();
}
module frontPanel2() {
effW=W+EXT*2;
punch() {
square([effW,SF2],center=true);
union() {
MRight(T/2) PLeft(W) TNutCageNotched(SF2,-2,tnutProfile,notchProfile,5,5); // walls
MLeft (T/2) PRight(W) TNutCageNotched(SF2,-2,tnutProfile,notchProfile,5,5);
PBottom(SF2) TNutCageNotched(W , 2,tnutProfile,notchProfile); // front
}
}
}
module frontPanel2Bolts() {
MRight(T/2) PLeft( W) notchRepeaterOutside(SF2-5-5,2) boltNut();
MLeft (T/2) PLeft(-W) notchRepeaterOutside(SF2-5-5,2) boltNut();
}
// to diagnose a part while designing,
// set debug to true and generate the part. ex:
// debug=true;
// walls();
//debug=true;
debug=false;
module punch() {
if (debug) {
color("green",0.5)
difference() {
children(0); children(1);
}
children(1);
} else {
difference() {
children(0); children(1);
}
}
}
}
//
// T-NUT WITH NOTCHES
//
// +-------------------+
// | +---+ +---+ | female
// | O | | O | | O | O = holes
// | +---+ +---+ |
// +-------------------+
//
// +---+ +---+
// | | | |
// +-#-+ +-#-+ +-#-+ male
// | # # # | # = bolts
// | # # # |
//
// note: if notches=0, a single t-nut cage and 2 small notches will be made
//
// +-----------------+
// | +--+ +--+ | female
// | | | O | | | O = hole
// | +--+ +--+ |
// +-----------------+
//
// +--+ +--+
// | | | |
// +--+ +--#--+ +--+ male
// | # | # = bolts
// | # |
module TNutCageNotched(targetWidth,notches,tnutProfile,notchProfile,leftGap=0,rightGap=0) {
if (notches==0 || notches==undef)
Exit( "TNutCageNotched(): notches cannot be 0, use *_M() or *_F() instead" );
if (notches>0)
TNutCageNotched_M(targetWidth,notches,tnutProfile,notchProfile,leftGap,rightGap);
else
TNutCageNotched_F(targetWidth,-notches,tnutProfile,notchProfile,leftGap,rightGap);
}
module TNutCageNotched_M(targetWidth,notches=0,tnutProfile,notchProfile,leftGap=0,rightGap=0) {
if ( notches <= 0 ) {
//
// SINGLE T-NUT CAGE (but put notches on both sides)
//
// +-+ +-+
// | | | | <-- add 2 notches
// +-+ +--#--+ +-+
// | # |
// | ### |
// | # |
// -->| |<-- targetWidth
overlap = 1; // extra on top for clean punch
nutDiameter = kvGet(tnutProfile,"nut.effDiameter");
notch = kvGet(notchProfile,"notch");
notchHeight = kvGet(notch,"height" );
nHa = kvGet(notch,"heightAllowance");
defaults = kvGet(notchProfile,"defaults");
gapLeft = kvGet(defaults,"leftGap");
gapRight = kvGet(defaults,"rightGap");
notchArea = (targetWidth-nutDiameter)/2;
translate([0,-notchHeight,0])
TNutCage_M(tnutProfile);
translate([-targetWidth/2+notchArea/2,0,0])
notchMale(notchArea,1,notchProfile,leftGap=-gapLeft,rightGap=-gapRight);
translate([targetWidth/2-notchArea/2,0,0])
notchMale(notchArea,1,notchProfile,leftGap=-gapLeft,rightGap=-gapRight);
translate([0,-notchHeight/2+abs(nHa)/2+overlap/2,0])
square([nutDiameter+2,notchHeight+abs(nHa)+overlap],center=true);
} else {
//
// MULTIPLE NOTCHES AND T-NUT CAGES
//
notchHeight = kvGet(notchProfile,"notch.height" );
defaults = kvGet(notchProfile,"defaults");
eGapLeft = kvGet(defaults,"leftGap") + leftGap;
eGapRight = kvGet(defaults,"rightGap") + rightGap;
width = targetWidth-eGapLeft-eGapRight;
// NOTCH
notchMale(targetWidth,notches,notchProfile,leftGap=leftGap,rightGap=rightGap);
// T-NUT
translate([(eGapLeft-eGapRight)/2,-notchHeight,0])
notchRepeaterOutside(width,notches)
TNutCage_M(tnutProfile);
}
}
module TNutCageNotched_F(targetWidth,notches=0,tnutProfile,notchProfile,leftGap=0,rightGap=0) {
if ( notches <= 0 ) {
//
// SINGLE T-NUT HOLE (but put notch holes on both sides)
//
nutDiameter = kvGet(tnutProfile, "nut.effDiameter" );
defaults = kvGet(notchProfile,"defaults");
gapLeft = kvGet(defaults,"leftGap");
gapRight = kvGet(defaults,"rightGap");
notchArea = (targetWidth-nutDiameter)/2;
TNutCage_F(tnutProfile);
translate([-targetWidth/2+notchArea/2,0,0])
notchFemale(notchArea,1,notchProfile,leftGap=-gapLeft,rightGap=-gapRight);
translate([targetWidth/2-notchArea/2,0,0])
notchFemale(notchArea,1,notchProfile,leftGap=-gapLeft,rightGap=-gapRight);
} else {
//
// MULTIPLE NOTCH HOLES AND T-NUT HOLES
//
defaults = kvGet(notchProfile,"defaults");
eGapLeft = kvGet(defaults,"leftGap") + leftGap;
eGapRight = kvGet(defaults,"rightGap") + rightGap;
width = targetWidth-eGapLeft-eGapRight;
// NOTCH
notchFemale(targetWidth,notches,notchProfile,leftGap=leftGap,rightGap=rightGap);
// T-NUT
translate([(eGapLeft-eGapRight)/2,0,0])
notchRepeaterOutside(width,notches)
TNutCage_F(tnutProfile);
}
}