-
Notifications
You must be signed in to change notification settings - Fork 0
/
boxbed.scad
298 lines (275 loc) · 9.85 KB
/
boxbed.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
// Bed box, inspired by http://www.instructables.com/id/Box-Bed/?ALLSTEPS
// by Wholman of http://www.objectguerilla.com/
// (but metric units, not medieval)
// Global variables
// Standard panel sizes
full_panel_length=2440;
full_panel_width=1220;
saw_width=2.8;
// The mattress itself
mattress_width=1600;
mattress_length=2000;
mattress_height=200;
// Wood panels
panel_length=2440;
panel_width=1220;
panel_thick_height=18;
panel_thin_height=12;
// Box dimensions
box_width=800;
box_length=1000;
box_inner_height=360;
box_outer_height=box_inner_height+panel_thick_height;
box_inner_length=box_length-panel_thin_height-panel_thick_height;
// Panel modules
dado_offset_1=25;
dado_offset_2=45;
dado_width=4;//will require two difficult parallell circular saw cuts!!
door_track_height=panel_thick_height;
door_track_length=box_inner_length;
door_track_width=76;
door_track_dado_height=3;
door_track_dado_width=dado_width;
door_track_dado_offset_1=dado_offset_1;
door_track_dado_offset_2=dado_offset_2;
panel_side_thick_height=panel_thick_height;
panel_side_thick_width=box_inner_height;
panel_side_thick_length=box_width;
panel_side_thin_height=panel_thin_height;
panel_side_thin_width=box_inner_height;
panel_side_thin_length=box_width;
panel_top_height=panel_thick_height;
panel_top_width=box_width;
panel_top_length=box_length;
panel_top_dado_offset_1=dado_offset_1;
panel_top_dado_offset_2=dado_offset_2;
panel_top_dado_height=9;
panel_top_dado_width=dado_width;
shelf_height=panel_thin_height;
shelf_width=460;
shelf_length=box_inner_length;
stiffening_rib_height=panel_thin_height;
stiffening_rib_width=box_inner_height;
stiffening_rib_length=box_inner_length;
door_height=3;
door_width=box_inner_height-door_track_height+(panel_top_dado_height-door_track_dado_height);;
door_length=box_inner_length/2+40; // 40mm overlap between door panels
/*---------------------------------------
Parts
---------------------------------------*/
// Mattress
module mattress(){
color("white") cube([mattress_width,mattress_length,mattress_height]);
}
// Box parts 2D
module door_left_2d(){
difference(){
square([door_length,door_width]);
translate([50,door_width/2,0])
circle(d=40);
}
}
module door_track_2d(){
square([door_track_length,door_track_width]);
}
module panel_side_thick_2d(){
square([panel_side_thick_length,panel_side_thick_width]);
}
module panel_side_thin_2d(){
square([panel_side_thin_length,panel_side_thin_width]);
}
module panel_top_2d(){
square([panel_top_length,panel_top_width]);
}
module shelf_2d(){
square([shelf_length,shelf_width]);
}
module stiffening_rib_2d(){
square([stiffening_rib_length,stiffening_rib_width]);
}
module thick_panel_1(){
% square([full_panel_length,full_panel_width]);
translate([panel_top_width,0]) rotate([0,0,90]) panel_top();
translate([2*panel_top_width+ saw_width,0]) rotate([0,0,90]) panel_top();
translate([3*panel_top_width+ 2*saw_width,0]) rotate([0,0,90]) panel_top();
translate([0,panel_top_length+saw_width]) door_track();
translate([0,panel_top_length+2*saw_width+door_track_width]) door_track();
translate([door_track_length+saw_width,panel_top_length+saw_width]) door_track();
translate([door_track_length+saw_width,panel_top_length+2*saw_width+door_track_width]) door_track();
}
module thick_panel_2(){
% translate([full_panel_length+20,0]){
square([full_panel_length,full_panel_width]);
panel_top();
translate([0,panel_top_width+saw_width]) panel_side_thick();
translate([panel_top_length+saw_width,0]){
panel_side_thick();
translate([0,panel_side_thick_width+saw_width]) panel_side_thick();
translate([0,2*(panel_side_thick_width+saw_width)]) panel_side_thick();
}
}
}
module thin_panel_1(){
translate([0,full_panel_width+20]){
// first thin panel
% square([full_panel_length,full_panel_width]);
shelf();
translate([shelf_length+saw_width,0])
shelf();
translate([0,shelf_width+saw_width])
stiffening_rib();
translate([shelf_length+saw_width,shelf_width+saw_width])
stiffening_rib();
translate([0,shelf_width+stiffening_rib_width+2*saw_width])
stiffening_rib();
translate([shelf_length+saw_width,shelf_width+stiffening_rib_width+2*saw_width])
stiffening_rib();
translate([2*(shelf_length+saw_width)+shelf_width,0])
rotate([0,0,90])
shelf();
}
}
module thin_panel_2(){
translate([full_panel_length+20,full_panel_width+20]){
% square([full_panel_length,full_panel_width]);
translate([shelf_width,0])
rotate([0,0,90])
shelf();
translate([shelf_width+saw_width+panel_side_thin_width,0])
rotate([0,0,90])
panel_side_thin();
translate([shelf_width+2*(saw_width+panel_side_thin_width),0])
rotate([0,0,90])
panel_side_thin();
translate([shelf_width+3*(saw_width+panel_side_thin_width),0])
rotate([0,0,90])
panel_side_thin();
translate([shelf_width+saw_width,panel_side_thin_length+saw_width])
panel_side_thin();
}
}
// Box parts 3D
module door_left(){
% linear_extrude(door_height) door_left_2d();
}
module door_right(){
translate([door_length,0,0])
mirror([1,0,0])
% door_left();
}
module door_track(){
difference(){
color("brown") linear_extrude(door_track_height) door_track_2d();
translate([0,door_track_dado_offset_1,door_track_height-door_track_dado_height])
cube([door_track_length,door_track_dado_width,door_track_dado_height]);
translate([0,door_track_dado_offset_2,door_track_height-door_track_dado_height])
cube([door_track_length,door_track_dado_width,door_track_dado_height]);
}
text=str("door track:",door_track_length,"mm* ",door_track_width,"mm *",door_track_height,"mm");
translate([door_track_length/2, door_track_width/2, door_track_height])
color("yellow") {
text(halign="center", valign="center", text=text, size=20);
}
}
module panel_side_thick(){
color("brown") linear_extrude(panel_side_thick_height) panel_side_thick_2d();
text=str("panel side thick:",panel_side_thick_length,"mm* ",panel_side_thick_width,"mm *",panel_side_thick_height,"mm");
translate([panel_side_thick_length/2, panel_side_thick_width/2, panel_side_thick_height])
color("yellow") {
text(halign="center", valign="center", text=text, size=20);
}
}
module panel_side_thin(){
linear_extrude(panel_side_thin_height) panel_side_thin_2d();
text=str("panel side thin:",panel_side_thin_length,"mm* ",panel_side_thin_width,"mm *",panel_side_thin_height,"mm");
translate([panel_side_thin_length/2, panel_side_thin_width/2, panel_side_thin_height])
color("blue") {
text(halign="center", valign="center", text=text, size=20);
}
}
module panel_top(){
difference(){
color("brown") linear_extrude(panel_top_height) panel_top_2d();
translate([0,panel_top_dado_offset_1,0])
cube([panel_top_length, panel_top_dado_width,panel_top_dado_height]);
translate([0,panel_top_dado_offset_2,0])
cube([panel_top_length, panel_top_dado_width,panel_top_dado_height]);
}
text=str("panel top:",panel_top_length,"mm* ",panel_top_width,"mm *",panel_top_height,"mm");
translate([panel_top_length/2, panel_top_width/2, panel_top_height])
color("yellow") {
text(halign="center", valign="center", text=text, size=20);
}
}
module shelf(){
linear_extrude(shelf_height) shelf_2d();
text=str("shelf:",shelf_length,"mm* ",shelf_width,"mm *",shelf_height,"mm");
translate([shelf_length/2, shelf_width/2, shelf_height])
color("blue") {
text(halign="center", valign="center", text=text, size=20);
}
}
module stiffening_rib(){
linear_extrude(stiffening_rib_height) stiffening_rib_2d();
text=str("stiffening rib:",stiffening_rib_length,"mm* ",stiffening_rib_width,"mm *",stiffening_rib_height,"mm");
translate([stiffening_rib_length/2, stiffening_rib_width/2, stiffening_rib_height])
color("blue") {
text(halign="center", valign="center", text=text, size=20);
}
}
// One box 3D
module box(){
translate([panel_thick_height,0,0])
door_track();
rotate([90,0,90])
panel_side_thick();
translate([box_length-panel_side_thin_height,0,0])
rotate([90,0,90])
panel_side_thin();
translate([0,0,box_inner_height])
panel_top();
translate([panel_side_thick_height,door_track_width,(box_inner_height+shelf_height)/2])
shelf();
translate([panel_thick_height,door_track_width+shelf_width+stiffening_rib_height,0])
rotate([90,0,0])
stiffening_rib();
translate([panel_side_thick_height,door_track_dado_offset_1+(door_height+dado_width)/2,door_track_height-door_track_dado_height])
rotate([90,0,0])
door_left();
translate([box_inner_length-door_length+panel_side_thick_height,door_track_dado_offset_2+(door_height+dado_width)/2,door_track_height-door_track_dado_height])
rotate([90,0,0])
door_right();
}
// All four boxes 3D
module boxes(){
box();
translate([2*box_length,0,0])
mirror([1,0,0])
box();
translate([0,2*box_width,0]){
mirror([0,1,0]){
box();
translate([2*box_length,0,0])
mirror([1,0,0])
box();
}
}
}
/*----------------------------------------
Build it!
Set 3d=1 for 3d view, or 3d=0 for 2d view.
----------------------------------------*/
3d=1;
if (3d){
// 3D view
boxes();
translate([mattress_length,0,box_outer_height])
rotate([0,0,90])
mattress();
} else {
// 2D view
thick_panel_1();
thick_panel_2();
thin_panel_1();
thin_panel_2();
}