-
Notifications
You must be signed in to change notification settings - Fork 1
/
standesk.scad
651 lines (567 loc) · 19 KB
/
standesk.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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
/**
* standesk - A customizable standing desk made out of just one plywood panel.
*
* WARNING: This model is a quick-and-dirty sketch! Although it is fully
* parametric, some settings might yield nonsense paths or break the
* model in unexpected ways! Feel free to contribute by opening PRs
* or issues on the official GitHub respository linked below.
*
* Version: 0.1.5
* Author: Joseph Paul <mail@jsph.pl>
* License: Public Domain
* URL: https://github.com/jsphpl/standesk
*/
/*
|-------------------------------------------------------------------------------
| Parameters (user-settable)
|-------------------------------------------------------------------------------
|
| The following variables should be set by the user in order
| to define the overall dimensions of the resulting desk.
|
| For instrucions on how to use this model, please refer to
| https://github.com/jsphpl/standesk
|
*/
DESK_HEIGHT = 1100; // mm // Height of the desk surface above the floor
DESK_WIDTH = 1120; // mm // Width of the desk surface between feet
DESK_DEPTH = 800; // mm // Depth of the desk surface between front and rear edge
TOOL_DIAMETER = 4; // mm // Diameter of the drill bit used to cut the material
CLEARANCE = 10; // mm // Extra space between individual Parts on the panel
CORNER_RADIUS = 10; // mm // Radius for rounding the outer corners
FILLET_RADIUS = TOOL_DIAMETER/1.9; // mm // Radius for dogbone fillets
STOCK_WIDTH = 1210; // mm // Width of one panel of the desired raw material
STOCK_LENGTH = 2480; // mm // Length of one panel of the desired raw material
STOCK_THICKNESS = 12; // mm // Thickness of the desired raw material
/**
* Global SCALE
*
* Increase/decrease to change the size of all joints and
* the width of all struts. This value basically lets
* you proportionally scale all other parameters
* than the ones defined above this comment.
*
* Please always check both the assembled and flat view
* of the model before producing the DXF outlines.
*/
SCALE = 1;
/*
|-------------------------------------------------------------------------------
| Output Options
|-------------------------------------------------------------------------------
|
| When FLAT is false, the assembled model will be rendered (3D).
|
| When FLAT is true, the parts will be shown the way they're
| arranged on the the stock panel. SHOW_STOCK can be used
| to check if everything fits on the panel.
|
| In order to produce the final DXF curves, both FLAT and
| PROJECTION must be set to `true`.
|
| If TEST_JOINT is true, a separate joint (male + female + pin)
| will be added to the FLAT view. These parts should be cut
| separately, prior to all other cuts, in order to ensure
| the parameters are correct for the material and thus
| the joints fit as desired, so you can assemble it.
|
*/
FLAT = false;
PROJECTION = false;
SHOW_STOCK = true;
TEST_JOINT = true;
$fn = 50;
/*
|-------------------------------------------------------------------------------
| Details
|-------------------------------------------------------------------------------
|
| The variables defined below should typically not need to be adjusted.
| Most of the time, only the primary dimensions (width, height, depth)
| as well as the stock and machine parameters should need adjustment.
|
*/
// Feet
BASE_HEIGHT = 200*SCALE;
STAND_DEPTH = 180*SCALE;
STAND_SPACE = 200*SCALE;
// Foot rest
REST_DEPTH = 130*SCALE;
REST_LEVEL = 240*SCALE;
REST_ANGLE = 15; // degrees
// Top Support (another strut right below the table top as a
// support when using thinner material, recommended < 15mm)
TOPSUPPORT_ON = true;
TOPSUPPORT_DEPTH = 110*SCALE;
// Crosses
CROSS_CUT = max(DESK_HEIGHT/7, 140)*SCALE; // 1/7th of DESK_HEIGHT if > 140mm
CROSS_CLEARANCE = 0;
CROSS_ANGLE = atan((DESK_HEIGHT - CROSS_CUT) / DESK_WIDTH);
CROSS_WIDTH = sin(90 - CROSS_ANGLE) * CROSS_CUT;
CROSS_SINGLE = true; // Use only one strut for the cross
// Joints
JOINT_WIDTH = 60*SCALE;
JOINT_LENGTH = 45*SCALE;
JOINT_TOLERANCE = 0;
JOINT_SLOT_WIDTH = STOCK_THICKNESS + JOINT_TOLERANCE;
JOINT_SLOT_LENGTH = STOCK_THICKNESS * 1.2;
JOINT_SLOT_OFFSET = STOCK_THICKNESS * 0.8;
JOINT_SLOT_TOLERANCE = .2;
JOINT_BUFFER = max(3.3*STOCK_THICKNESS, 6); // at least 6mm
// Keys
KEY_LENGTH = 50*SCALE;
KEY_THICKNESS = STOCK_THICKNESS * 1.2;
// Flat Offsets
CROSSES_FLAT_OFFSET_X = DESK_DEPTH + JOINT_LENGTH/2 + CLEARANCE;
CROSSES_FLAT_OFFSET_Y = DESK_DEPTH + CLEARANCE;
/*
|-------------------------------------------------------------------------------
| Includes
|-------------------------------------------------------------------------------
*/
include <library.scad>;
/*
|-------------------------------------------------------------------------------
| Model
|-------------------------------------------------------------------------------
|
| The actual model
|
*/
/**
* The table top surface.
*/
module top() {
trans = FLAT ? [DESK_DEPTH, JOINT_LENGTH+1, 0] : [0, 0, DESK_HEIGHT];
rot = FLAT ? [0, 0, 90] : [0, 0, 0];
translate(trans)
rotate(rot)
difference() {
union() {
cube(size = [DESK_WIDTH, DESK_DEPTH, STOCK_THICKNESS]);
// Joints
// left
translate([0, DESK_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
joint();
translate([0, STAND_SPACE + STAND_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
joint();
// right
translate([DESK_WIDTH, DESK_DEPTH - (STAND_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, 90])
joint();
translate([DESK_WIDTH, STAND_SPACE + (STAND_DEPTH - JOINT_WIDTH) / 2, 0])
rotate([90, 0, 90])
joint();
}
// Rounded corners
roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, 0, 0]) rotate([0, 0, 90]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, DESK_DEPTH, 0]) rotate([0, 0, 180]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([0, DESK_DEPTH, 0]) rotate([0, 0, 270]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
// Fillets
// left
translate([0, DESK_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2, 0]) rotate([0, 0, 90]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([0, DESK_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2 - JOINT_WIDTH, 0]) rotate([0, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([0, STAND_SPACE + STAND_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2, 0]) rotate([0, 0, 90]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([0, STAND_SPACE + STAND_DEPTH - (STAND_DEPTH - JOINT_WIDTH) / 2 - JOINT_WIDTH, 0]) rotate([0, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
// right
translate([DESK_WIDTH, DESK_DEPTH - (STAND_DEPTH + JOINT_WIDTH) / 2, 0]) rotate([0, 0, 270]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, DESK_DEPTH - (STAND_DEPTH + JOINT_WIDTH) / 2 + JOINT_WIDTH, 0]) rotate([0, 0, 0]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, STAND_SPACE + (STAND_DEPTH - JOINT_WIDTH) / 2, 0]) rotate([0, 0, 270]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, STAND_SPACE + (STAND_DEPTH - JOINT_WIDTH) / 2 + JOINT_WIDTH, 0]) rotate([0, 0, 0]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
}
}
/**
* Both complete feet.
*/
module feet() {
if (FLAT)
{
translate([DESK_DEPTH + CLEARANCE, -CLEARANCE, STOCK_THICKNESS])
{
rotate([0, 180, 0])
{
translate([0, CLEARANCE, 0])
rotate([0, -90, 0])
foot("left");
translate([-DESK_HEIGHT -JOINT_BUFFER -CLEARANCE -BASE_HEIGHT, DESK_DEPTH+CLEARANCE, 0])
rotate([0, -90, 180])
foot("right");
}
}
}
else
{
translate([-STOCK_THICKNESS, 0, 0])
{
foot("left");
translate([DESK_WIDTH + STOCK_THICKNESS, 0, 0])
foot("right");
}
}
}
/**
* A complete foot (left or right) with holes cut out.
*
* @param {String} side Which side foot (left|right)
*/
module foot(side) {
if (side == "left")
{
// left
difference() {
baseFoot();
// holes
union() {
// top
translate([0, STAND_SPACE + (STAND_DEPTH - JOINT_WIDTH)/2, DESK_HEIGHT])
rotate([90, 0, 90])
jointHole();
translate([0, DESK_DEPTH - (STAND_DEPTH + JOINT_WIDTH)/2, DESK_HEIGHT])
rotate([90, 0, 90])
jointHole();
// cross
translate([0, DESK_DEPTH + CROSS_CLEARANCE - STAND_DEPTH/2, (CROSS_CUT + JOINT_WIDTH)/2])
rotate([0, 90, 0])
jointHole();
translate([0, DESK_DEPTH - STAND_DEPTH/2 - (STOCK_THICKNESS + CROSS_CLEARANCE), DESK_HEIGHT - (CROSS_CUT - JOINT_WIDTH)/2])
rotate([0, 90, 0])
jointHole();
// rest
translate([STOCK_THICKNESS, STAND_SPACE + (STAND_DEPTH - REST_DEPTH)/2, REST_LEVEL])
rotate([REST_ANGLE, 0, 0])
translate([0, (REST_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
jointHole();
// support
translate([0, STAND_SPACE + (STAND_DEPTH+STOCK_THICKNESS)/2, DESK_HEIGHT-TOPSUPPORT_DEPTH])
rotate([90, 0, 0])
translate([STOCK_THICKNESS, (TOPSUPPORT_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
jointHole();
}
}
}
if (side == "right")
{
//right
difference() {
baseFoot();
// holes
union() {
// top
translate([0, STAND_SPACE + (STAND_DEPTH - JOINT_WIDTH)/2, DESK_HEIGHT])
rotate([90, 0, 90])
jointHole();
translate([0, DESK_DEPTH - (STAND_DEPTH + JOINT_WIDTH)/2, DESK_HEIGHT])
rotate([90, 0, 90])
jointHole();
// cross
translate([0, DESK_DEPTH - STAND_DEPTH/2 - (STOCK_THICKNESS + CROSS_CLEARANCE), (CROSS_CUT + JOINT_WIDTH)/2])
rotate([0, 90, 0])
jointHole();
translate([0, DESK_DEPTH - STAND_DEPTH/2 + CROSS_CLEARANCE, DESK_HEIGHT - (CROSS_CUT - JOINT_WIDTH)/2])
rotate([0, 90, 0])
jointHole();
// rest
translate([STOCK_THICKNESS, STAND_SPACE + (STAND_DEPTH - REST_DEPTH)/2, REST_LEVEL])
rotate([REST_ANGLE, 0, 0])
translate([0, (REST_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
jointHole();
// support
translate([STOCK_THICKNESS, STAND_SPACE + (STAND_DEPTH+STOCK_THICKNESS)/2, DESK_HEIGHT-TOPSUPPORT_DEPTH])
rotate([90, 0, 0])
translate([0, (TOPSUPPORT_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
jointHole();
}
}
}
}
/**
* A Single Table Foot without holes.
*/
module baseFoot() {
union() {
// base
difference() {
cube(size = [STOCK_THICKNESS, DESK_DEPTH, BASE_HEIGHT]);
// Rounded corners
rotate([90, 0, 90]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([0, 0, BASE_HEIGHT]) rotate([0, 90, 0]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([0, DESK_DEPTH, 0]) rotate([180, -90, 0]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
}
// 2 stands
translate([0, DESK_DEPTH - STAND_DEPTH, 0])
footStand();
translate([0, STAND_SPACE, 0])
footStand();
// Rounded corners
translate([0, STAND_SPACE+ STAND_DEPTH, BASE_HEIGHT]) rotate([90, 0, 90]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([0, STAND_SPACE, BASE_HEIGHT]) rotate([90, 270, 90]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([0, DESK_DEPTH-STAND_DEPTH, BASE_HEIGHT]) rotate([90, 270, 90]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
}
}
/**
* One vertical strut with holes cut out. Needed twice per foot.
*/
module footStand() {
totalHeight = DESK_HEIGHT + JOINT_BUFFER;
difference() {
cube(size = [STOCK_THICKNESS, STAND_DEPTH, totalHeight]);
// Rounded corners
translate([0, 0, totalHeight]) rotate([0, 90, 0]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([STOCK_THICKNESS, STAND_DEPTH, totalHeight]) rotate([0, 90, 180]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
}
}
/**
* Both crosses.
*/
module crosses() {
if(FLAT)
{
translate([CROSSES_FLAT_OFFSET_X, CROSSES_FLAT_OFFSET_Y, 0])
{
cross();
if (! CROSS_SINGLE) {
translate([0, CROSS_WIDTH + CLEARANCE, 0])
cross();
}
}
}
else
{
translate([0, DESK_DEPTH - STAND_DEPTH/2, 0])
union() {
// cross 1
translate([0, STOCK_THICKNESS + CROSS_CLEARANCE, 0])
cross();
if (! CROSS_SINGLE) {
// cross 2
translate([DESK_WIDTH, -CROSS_CLEARANCE, 0])
mirror([1, 0, 0])
cross();
}
}
}
}
/**
* A single diagonal strut.
*/
module cross() {
rotX1 = FLAT ? 0 : 90;
rotX2 = FLAT ? -90 : 0;
rotZ = FLAT ? -CROSS_ANGLE : 0;
rotate([0, 0, rotZ])
difference() {
union() {
rotate([rotX1, 0, 0])
linear_extrude(height = STOCK_THICKNESS)
polygon(
points = [
[0, 0],
[DESK_WIDTH, DESK_HEIGHT - CROSS_CUT],
[DESK_WIDTH, DESK_HEIGHT],
[0, CROSS_CUT]
],
paths = [
[0, 1, 2, 3]
]
);
// Joints
rotate([rotX2, 0, 0]) {
translate([0, -STOCK_THICKNESS, (CROSS_CUT - JOINT_WIDTH)/2])
rotate([0, -90, 0])
joint();
translate([DESK_WIDTH, -STOCK_THICKNESS, DESK_HEIGHT- (CROSS_CUT - JOINT_WIDTH)/2])
rotate([0, 90, 0])
joint();
}
}
// Fillets
rotate([rotX2, 0, 0]) {
translate([2, -STOCK_THICKNESS, (CROSS_CUT - JOINT_WIDTH)/2]) rotate([90, 90, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([2, -STOCK_THICKNESS, (CROSS_CUT - JOINT_WIDTH)/2 + JOINT_WIDTH]) rotate([90, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, -STOCK_THICKNESS, DESK_HEIGHT- (CROSS_CUT - JOINT_WIDTH)/2]) rotate([90, 270, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, -STOCK_THICKNESS, DESK_HEIGHT- (CROSS_CUT - JOINT_WIDTH)/2 - JOINT_WIDTH]) rotate([90, 180, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
}
}
}
/**
* The lower horizontal bar intened as a foot rest.
*/
module rest() {
rot = FLAT ? [0, 0, 0] : [REST_ANGLE, 0, 0];
trans = FLAT ? [DESK_DEPTH + JOINT_LENGTH + CLEARANCE + 1, CROSSES_FLAT_OFFSET_Y + 2*CROSS_WIDTH +3*CLEARANCE, 0] : [0, STAND_SPACE + (STAND_DEPTH - REST_DEPTH)/2, REST_LEVEL];
translate(trans)
rotate(rot)
difference() {
union() {
cube([DESK_WIDTH, REST_DEPTH, STOCK_THICKNESS]);
// joints
translate([0, (REST_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
joint();
translate([DESK_WIDTH, (REST_DEPTH - JOINT_WIDTH) / 2, 0])
rotate([90, 0, 90])
joint();
}
// Fillets
translate([0, (REST_DEPTH + JOINT_WIDTH) / 2, 0]) rotate([0, 0, 90]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([0, (REST_DEPTH + JOINT_WIDTH) / 2 - JOINT_WIDTH, 0]) rotate([0, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, (REST_DEPTH - JOINT_WIDTH) / 2, 0]) rotate([0, 0, 270]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, (REST_DEPTH - JOINT_WIDTH) / 2 + JOINT_WIDTH, 0]) rotate([0, 0, 0]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
}
}
/**
* The top support strut. Intended to reinforce the
* table top when using thin stock material.
*/
module topsupport() {
if (TOPSUPPORT_ON) {
rot = FLAT ? [0, 0, 0] : [90, 0, 0];
trans = FLAT ? [CROSSES_FLAT_OFFSET_X + 3*CLEARANCE, CROSSES_FLAT_OFFSET_Y + CROSS_WIDTH + CLEARANCE, 0] : [0, STAND_SPACE + (STAND_DEPTH+STOCK_THICKNESS)/2, DESK_HEIGHT-TOPSUPPORT_DEPTH];
translate(trans)
rotate(rot)
difference() {
union() {
cube([DESK_WIDTH, TOPSUPPORT_DEPTH, STOCK_THICKNESS]);
// joints
translate([0, (TOPSUPPORT_DEPTH + JOINT_WIDTH) / 2, 0])
rotate([90, 0, -90])
joint();
translate([DESK_WIDTH, (TOPSUPPORT_DEPTH - JOINT_WIDTH) / 2, 0])
rotate([90, 0, 90])
joint();
}
// Fillets
translate([0, (TOPSUPPORT_DEPTH + JOINT_WIDTH) / 2, 0]) rotate([0, 0, 90]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([0, (TOPSUPPORT_DEPTH + JOINT_WIDTH) / 2 - JOINT_WIDTH, 0]) rotate([0, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, (TOPSUPPORT_DEPTH - JOINT_WIDTH) / 2, 0]) rotate([0, 0, 270]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([DESK_WIDTH, (TOPSUPPORT_DEPTH - JOINT_WIDTH) / 2 + JOINT_WIDTH, 0]) rotate([0, 0, 0]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
}
}
}
/**
* The male part of a joint, with a hole for the key.
*/
module joint() {
translate([0, 0, -0.5])
difference() {
cube([JOINT_WIDTH, STOCK_THICKNESS, JOINT_LENGTH + 1]);
// Rounded corners
translate([0, STOCK_THICKNESS, JOINT_LENGTH + 1]) rotate([90, 90, 0]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([JOINT_WIDTH, STOCK_THICKNESS, JOINT_LENGTH + 1]) rotate([90, 180, 0]) roundCorner(CORNER_RADIUS, STOCK_THICKNESS);
translate([
(JOINT_WIDTH - JOINT_SLOT_WIDTH) / 2,
0,
0
])
translate([0, STOCK_THICKNESS+1, JOINT_SLOT_OFFSET])
rotate([90, 0, 0])
dogboneCube([JOINT_SLOT_WIDTH, JOINT_SLOT_LENGTH, STOCK_THICKNESS + 2], FILLET_RADIUS);
}
}
/**
* The female part of a joint. This one is positive
* and intended to be subtractad from other objects.
*/
module jointHole() {
translate([-JOINT_SLOT_TOLERANCE/2, -JOINT_SLOT_TOLERANCE/2, -JOINT_SLOT_TOLERANCE/2])
dogboneCube([JOINT_WIDTH + JOINT_SLOT_TOLERANCE, STOCK_THICKNESS + JOINT_SLOT_TOLERANCE, STOCK_THICKNESS + JOINT_SLOT_TOLERANCE], FILLET_RADIUS);
}
/**
* All keys next to each other.
*/
module keys() {
if (FLAT) {
translate([DESK_DEPTH + DESK_HEIGHT + BASE_HEIGHT + 8*CLEARANCE, CLEARANCE, 0])
for(n = [0 : 9]) {
translate([0, (KEY_THICKNESS + CLEARANCE) * n, 0])
key();
}
}
}
/**
* A single key.
*/
module key() {
linear_extrude(height = STOCK_THICKNESS)
polygon([[0, 0], [KEY_LENGTH, 0], [0, KEY_THICKNESS]]);
}
/**
* Male and female part of a joint plus key for test cutting.
*/
module jointTest() {
if (FLAT) {
FEMALE_X = STOCK_THICKNESS*3;
FEMALE_Y = JOINT_WIDTH+2*STOCK_THICKNESS;
translate([STOCK_LENGTH - FEMALE_X - CLEARANCE, CLEARANCE, 0]) {
// Female
difference() {
cube([FEMALE_X, FEMALE_Y, STOCK_THICKNESS]);
translate([2*STOCK_THICKNESS, STOCK_THICKNESS, 0]) rotate([0, 0, 90]) jointHole();
}
// Male
translate([-(FEMALE_X + 2*CLEARANCE), CLEARANCE + STOCK_THICKNESS, 0])
rotate([0, 0, 90])
difference() {
union() {
translate([-STOCK_THICKNESS, 0, 0]) cube([JOINT_WIDTH+2*STOCK_THICKNESS, 2*STOCK_THICKNESS, STOCK_THICKNESS]);
rotate([90, 0, 0]) joint();
}
// Fillets
rotate([0, 0, 180]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
translate([JOINT_WIDTH, 0, 0]) rotate([0, 0, 270]) fillet(FILLET_RADIUS, STOCK_THICKNESS);
}
// Key
translate([0, FEMALE_Y + CLEARANCE, 0]) key();
}
}
}
/**
* The full desk.
*/
module desk() {
feet();
top();
crosses();
rest();
topsupport();
keys();
}
/**
* The stock panel as a reference.
*/
module stock(){
cube([STOCK_LENGTH, STOCK_WIDTH, STOCK_THICKNESS]);
}
/**
* Render either the desk or the joint tests.
*/
module show() {
desk();
if (TEST_JOINT) {
jointTest();
}
}
/*
|-------------------------------------------------------------------------------
| Rendering logic
|-------------------------------------------------------------------------------
*/
if (FLAT && PROJECTION) {
projection(cut = true)
translate([0, 0, -STOCK_THICKNESS/2])
show();
}
else {
show();
}
if (FLAT && SHOW_STOCK)
{
%stock();
}