Add also right-opening door functionality

Signed-off-by: Jacob Kiers <jacob@jacobkiers.net>
This commit is contained in:
Jacob Kiers 2022-01-08 22:16:56 +01:00
parent 60f7c8e24f
commit 517d37b91d
2 changed files with 70 additions and 19 deletions

View File

@ -3,7 +3,10 @@
// Usage: door(open_rotation = 45)
// The open_rotation parameter rotates the door in the z-plane.
module door(open_rotation = 45) {
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;
@ -14,17 +17,28 @@ module door(open_rotation = 45) {
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([
door_width + 2 * door_to_frame + 2 * (frame_outer_list_width + frame_outer_receded_width),
door_depth + 2 * frame_depth,
door_to_ground + door_height + door_to_frame + frame_depth
full_width(),
full_depth(),
full_height()
]);
translate([frame_outer_list_width, 0, 0]) door_list_receded();
}
@ -43,6 +57,20 @@ module door(open_rotation = 45) {
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,
@ -56,3 +84,19 @@ module door(open_rotation = 45) {
]);
}
}
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;
}

7
house/door_test.scad Normal file
View File

@ -0,0 +1,7 @@
include <door.scad>
distance = 1150;
door();
translate([distance, 0, 0]) door(door_position = DOOR_RIGHT);