$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; 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(length, translation, rotation) { translate(translation) rotate(rotation) linear_extrude(length) intersection() { circle(r=corner_radius); square(corner_radius*2); } } /* 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]); /* Top edge */ round_edge( 2 * pcb_clearance_edge + pcb_width, [0 - pcb_clearance_edge, pcb_clearance_edge + pcb_height, 0], [0, 90, 0]); /* Right edge */ round_edge( 2 * pcb_clearance_edge + pcb_height, [ pcb_clearance_edge + pcb_width, 0 - pcb_clearance_edge, 0], [270, 0, 0]); /* Bottom edge */ round_edge(2 * pcb_clearance_edge + pcb_width, [0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [90, 180, 90]); /* Left edge */ round_edge( 2 * pcb_clearance_edge + pcb_height, [0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0], [270, 90, 0]); linear_extrude(thickness) translate([0 - pcb_clearance_edge, 0 - pcb_clearance_edge, 0]) square([2 * pcb_clearance_edge + pcb_width, 2 * pcb_clearance_edge + pcb_height], false); } keyboard_base_plate(pcb_width, pcb_height);