construction_plans/shelf_with_drawers.scad

169 lines
4.3 KiB
OpenSCAD

/* Copyright © 2020 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* A shelf with cubical drawers. Units are supposed to be cm. You will need 1
* kind of lath, 1 kind of board, handles, a saw, a drill and a few screws for
* this build.
*/
$fa = 1;
$fs = 0.2;
drawer_size = 20; /* Cube */
drawers_number = 4; /* Number of drawers */
drawers_begin = 80; /* Begin rendering drawers at this height */
lath_width = 2.4; /* x */
lath_depth = 4.8; /* y */
board_height = 1.6; /* z */
module drawer()
{
/* Sides */
color("brown")
{
translate([0, board_height, 0])
{
cube([board_height, drawer_size - (board_height * 2), drawer_size]);
}
translate([drawer_size - board_height, board_height, 0])
{
cube([board_height, drawer_size - (board_height * 2), drawer_size]);
}
}
/* Front & back */
color("darkred")
{
cube([drawer_size, board_height, drawer_size]);
translate([board_height - board_height, drawer_size - board_height, 0])
{
cube([drawer_size, board_height, drawer_size]);
}
}
/* Bottom */
color([0.4, 0.2, 0.2])
{
translate([board_height, board_height, 0])
{
cube([
drawer_size - (board_height * 2),
drawer_size - (board_height * 2),
board_height
]);
}
}
/* Handle */
translate([drawer_size / 2, 0, drawer_size / 2])
{
color([0.4, 0.2, 0.2])
{
rotate([90, 0, 0])
{
cylinder(h = 0.5, d = 1.5);
}
translate([0, -1.5, 0])
{
sphere(d = 3, false);
}
}
}
}
module lath(length)
{
cube([lath_width, lath_depth, length]);
}
module shelf()
{
function post_height() = drawers_begin + (drawer_size * drawers_number)
+ (board_height * drawers_number + board_height);
/* Posts */
color("olive")
{
for (x = [0, drawer_size + lath_width])
{
for (y = [0, drawer_size - lath_depth])
{
translate([x, y, 0])
{
lath(post_height());
}
}
}
}
/* Cross laths */
color("darkgreen")
{
for (x = [0, drawer_size + lath_width])
{
/* Bottom */
for (z = [drawer_size:40:drawers_begin - lath_depth])
{
translate([x, drawer_size - lath_depth, z])
{
rotate([90, 0, 0])
{
lath(drawer_size - lath_depth * 2);
}
}
}
/* Top */
translate(
[x, drawer_size - lath_depth, post_height() - lath_depth - 10])
{
rotate([90, 0, 0])
{
lath(drawer_size - lath_depth * 2);
}
}
}
}
/* Bottoms */
function bottom_pos(number) =
drawers_begin + (drawer_size * number) + (board_height * number);
color([0.2, 0.4, 0.2])
{
for (number = [0:drawers_number])
translate([lath_width, 0, bottom_pos(number)])
{
cube([drawer_size, drawer_size, board_height]);
}
}
}
translate([5, 0, 0])
{
shelf();
translate([lath_width, drawer_size * -0.5, drawers_begin + board_height])
{
for (number = [0:drawers_number - 1])
{
translate([0, 0, (drawer_size * number) + (board_height * number)])
{
drawer();
}
}
}
}