cad/house/door.scad

102 lines
2.4 KiB
OpenSCAD
Raw Normal View History

// Builds a door with default measurements
// Usage: door(open_rotation = 45)
// The open_rotation parameter rotates the door in the z-plane.
DOOR_LEFT = "left";
DOOR_RIGHT = "right";
module door(open_rotation = 45, door_position = DOOR_LEFT) {
frame_depth = 65;
frame_outer_list_width = 45;
frame_outer_receded_width = 15;
door_width = 775;
door_depth = 50;
door_height = 2100;
door_to_ground = 15;
door_to_frame = 3;
if (door_position == DOOR_LEFT) {
door_outline();
//door_list_receded();
door_door();
}
if (door_position == DOOR_RIGHT) {
translate([full_width(), full_depth(), 0])
rotate([0, 0, 180]) {
door_outline();
//door_list_receded();
door_door();
}
}
module door_outline()
{
difference() {
cube([
full_width(),
full_depth(),
full_height()
]);
translate([frame_outer_list_width, 0, 0]) door_list_receded();
}
}
module door_list_receded()
{
difference() {
color("yellow") cube([
door_width + 2 * door_to_frame + 2 * frame_outer_receded_width,
door_depth + 2 * frame_depth,
door_to_ground + door_height + door_to_frame
]);
}
}
module door_door()
{
if (door_position == DOOR_LEFT) {
translate([
frame_depth + door_to_frame,
frame_depth,
door_to_ground
])
rotate([0, 0, open_rotation])
cube([
door_width,
door_depth,
door_height
]);
}
if (door_position == DOOR_RIGHT) {
translate([
frame_depth + door_to_frame,
frame_depth,
door_to_ground
])
rotate([0, 0, open_rotation])
cube([
door_width,
door_depth,
door_height
]);
}
}
function full_width() =
door_width +
2 * door_to_frame +
2 * (frame_outer_list_width + frame_outer_receded_width);
function full_depth() =
door_depth +
2 * frame_depth;
function full_height() =
door_to_ground +
door_height +
door_to_frame +
frame_depth;
}