$fn = 72; pcb_width = 257.175; pcb_height = 95.250; module keyboard_base_plate(pcb_width, pcb_height) { pcb_clearance_edge = 1.0; pcb_clearance_bottom = 2.0; thickness = 2.0; wall_height = 14.0; corner_radius = thickness / 2.0; module round_corner(translation, rotation) { translate(translation) rotate(rotation) rotate_extrude(angle=90) { intersection() { circle(r=corner_radius); square(corner_radius*2); } } } module round_edge(translation, rotation, length) { translate(translation) rotate(rotation) linear_extrude(length) intersection() { circle(r=corner_radius); square(corner_radius*2); } } module side(translation, dimensions) { translate(translation) linear_extrude(dimensions[2]) square([dimensions[0], dimensions[1]], false); } module wall_corner(translation, rotation, radius, length) { translate(translation) rotate(rotation) linear_extrude(length) intersection() { circle(r=radius); square([radius, radius], false); } } /* Lower left corner */ round_corner([0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [-90, 90, 90]); /* Upper left orner */ round_corner([0 - pcb_clearance_edge, pcb_clearance_edge + pcb_height, 0], [0, 90, 90]); /* Upper right corner */ round_corner([pcb_clearance_edge + pcb_width, pcb_clearance_edge + pcb_height, 0], [90, 90, 90]); /* Lower right corner */ round_corner([ pcb_clearance_edge + pcb_width, 0 - pcb_clearance_edge, 0], [180, 90, 90]); /* Upper edge */ round_edge([0 - pcb_clearance_edge, pcb_clearance_edge + pcb_height, 0], [0, 90, 0], 2 * pcb_clearance_edge + pcb_width); /* Right edge */ round_edge([ pcb_clearance_edge + pcb_width, 0 - pcb_clearance_edge, 0], [270, 0, 0], 2 * pcb_clearance_edge + pcb_height); /* Lower edge */ round_edge([0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [90, 180, 90], 2 * pcb_clearance_edge + pcb_width); /* Left edge */ round_edge([0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [270, 90, 0], 2 * pcb_clearance_edge + pcb_height); /* Upper right wall corner */ wall_corner([pcb_clearance_edge + pcb_width, pcb_clearance_edge + pcb_height, 0], [0, 0, 0], corner_radius, wall_height); /* Lower right wall corner */ wall_corner([ pcb_clearance_edge + pcb_width, 0 - pcb_clearance_edge, 0], [0, 0, 270], corner_radius, wall_height); /* Lower left wall corner */ wall_corner([0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [0, 0, 180], corner_radius, wall_height); /* Upper left wall corner */ wall_corner([0 - pcb_clearance_edge, pcb_clearance_edge + pcb_height, 0], [0, 0, 90], corner_radius, wall_height); /* Upper wall */ side([ 0 - pcb_clearance_edge, pcb_height, 0], [thickness + pcb_width, thickness, wall_height]); /* Right wall */ side([pcb_width, 0 - pcb_clearance_edge, 0], [thickness, thickness + pcb_height, wall_height]); /* Lower wall */ side([0 - pcb_clearance_edge, 0 - thickness, 0], [thickness + pcb_width, thickness, wall_height]); /* Left wall */ side([0 - thickness, 0 - pcb_clearance_edge, 0], [thickness, thickness + pcb_height, wall_height]); /* Bottom plate */ side([ 0 - pcb_clearance_edge, 0 - pcb_clearance_edge, -thickness / 2], [2 * pcb_clearance_edge + pcb_width, 2 * pcb_clearance_edge + pcb_height, thickness]); } keyboard_base_plate(pcb_width, pcb_height);