Skip to content

Instantly share code, notes, and snippets.

@guidoism
Created December 9, 2021 17:41
Show Gist options
  • Save guidoism/07e7e294a32f967c623cda839076f9bb to your computer and use it in GitHub Desktop.
Save guidoism/07e7e294a32f967c623cda839076f9bb to your computer and use it in GitHub Desktop.
$fn = 50;
include <Round-Anything/polyround.scad>
include <NopSCADlib/core.scad>
include <NopSCADlib/vitamins/pcbs.scad>
use <NopSCADlib/vitamins/pcb.scad>
include <BOSL2/std.scad>
include <BOSL2/partitions.scad>
include <BOSL2/screws.scad>
/*
%translate([180.5, 0, -15])
rotate([-3, 0, 0])
import("/Users/guido/Downloads/Real+Size+MacBook+Air+(OBJ+&+STL)/files/Computer.stl");
*/
/*
Height: 0.16–0.63 inch (0.41–1.61 cm)
Width: 11.97 inches (30.41 cm)
Depth: 8.36 inches (21.24 cm)
*/
/*
Metapost:
for i=0 upto 11:
draw (i*19, 0);
endfor
for i=0 upto 19:
draw (i*2.54, 21);
endfor
for i=0 upto 11:
x := i*2.54 + (3*2.54);
if i >= 4: x := x + 2.54; fi;
if i >= 8: x := x + 2.54; fi;
draw (x, 21){dir -90}..tension 2.1..{dir -90}(i*19, 0);
endfor
j := 0;
x := j*2.54;
if j >= 4: x := x + 2.54; fi;
if j >= 8: x := x + 2.54; fi;
draw (x, 21){dir -90}..{dir -90}(-1, 0);
j := 1;
x := j*2.54;
if j >= 4: x := x + 2.54; fi;
if j >= 8: x := x + 2.54; fi;
draw (x, 21){dir -90}..{dir -90}(-1, 0);
j := 15;
x := j*2.54;
if j >= 4: x := x + 2.54; fi;
if j >= 8: x := x + 2.54; fi;
if j >= 12: x := x + 2.54; fi;
draw (x, 21){dir -90}..tension 2.1..{dir -90}(19*11+1, 0);
j := 16;
x := j*2.54;
if j >= 4: x := x + 2.54; fi;
if j >= 8: x := x + 2.54; fi;
if j >= 12: x := x + 2.54; fi;
draw (x, 21){dir -90}..tension 2.1..{dir -90}(19*11+1, 0);
*/
// Which of the four parts to show (makes it a lot easier for exporting and printing)
parts = [0, 0, 0, 1];
points = [
[10, -2, 5 ],
[294, -2, 5 ],
[294, 96, 5 ],
[270, 96, 5 ],
[270, 122, 5 ],
[34, 122, 5 ],
[34, 96, 5 ],
[10, 96, 5 ],
];
knurled_nut_diameter = 4.2;
screw_shank_diameter = 3.0;
module embedded_nut_m3() {
rotate([0, 90, 0])
cylinder(h=5.75, d=knurled_nut_diameter, center=true);
}
module embedded_nuts() {
// Well for screw holder thingy
translate([294-6.7, 10, 2]) embedded_nut_m3();
translate([294-6.7, 90, 2]) embedded_nut_m3();
translate([15.8, 10, 2]) embedded_nut_m3();
translate([15.8, 90, 2]) embedded_nut_m3();
}
module keyboard() {
difference() {
union() {
color("cyan") linear_extrude(6) polygon(polyRound(points, 30));
}
translate([9, -5, -1]) cube([4, 120, 5]);
translate([290.1, -5, -1]) cube([4, 120, 5]);
embedded_nuts();
for ( x = [0:11], y = [0:3] ) {
// Holes for key switches
translate([x*19+38, y*19+3, -1])
cube([14, 14, 6]);
// Wells for columns
translate([x*19+38+6, 10, -1])
cube([2, 80, 3]);
}
translate([38, 5, -1]) cube([19*11, 2, 3]);
translate([38, 5+19, -1]) cube([19*11, 2, 3]);
translate([38, 5+(19*2), -1]) cube([19*11, 2, 3]);
translate([38, 5+(19*3), -1]) cube([19*11, 2, 3]);
// Deep well for chips
translate([60, 109, -1]) cube([53, 21.5, 5], center=true);
// Wide well for edges
translate([60, 109, -1]) cube([53, 21.5-1.7-1.7, 10], center=true);
// Hole for button
translate([37.5+10, 109+4.8+1-11.4+2, 1]) cylinder(h=10, r=4);
// Wires
//translate([45, 74, -1]) scale([2.85, 3.2, 1]) linear_extrude(3) import("lappy keyboard wires.svg");
//translate([38, 73, -2]) cube([210, 26, 4]);
// Far side rows
translate([0, 0, -2]) linear_extrude(4) polygon(polyRound([
[81, 101, 0],
[260, 101, 3],
[263, 70, 3],
[263, 3, 3],
[260, 3, 0],
[260, 70, 3],
[258, 97, 3],
[81, 97, 3],
], 30));
// Near side rows
translate([0, 0, -2]) linear_extrude(4) polygon(polyRound([
[38, 3, 0],
[36, 3, 3],
[36, 120, 0],
[40, 109, 0],
], 30));
// Columns
translate([0, 0, -2]) linear_extrude(4) polygon(polyRound([
[42, 85, 5],
[42, 110, 0],
[80, 110, 0],
[80, 85, 5],
], 30));
translate([0, 0, -2]) linear_extrude(4) polygon(polyRound([
[75, 85, 0],
[80, 95, 0],
[255, 95, 5],
[255, 85, 0],
], 30));
// Depression to top of keys
translate([0, 0, 4.3]) linear_extrude(10) polygon(polyRound([
[30, -3, 0],
[270, -3, 0],
[270, 80, 5],
[30, 80, 5],
], 30));
}
// Standoff thingies
color("red") {
translate([37.5, 109+4.8+1, 0]) cylinder(h=4, r=1.025);
translate([37.5, 109+4.8+1-11.4, 0]) cylinder(h=4, r=1.025);
translate([37.5+47, 109+4.8+1, 0]) cylinder(h=4, r=1.025);
translate([37.5+47, 109+4.8+1-11.4, 0]) cylinder(h=4, r=1.025);
}
}
module bottom_plate() {
difference() {
union() {
color("purple") translate([0, 0, -2]) linear_extrude(2) polygon(polyRound(points, 30));
//color("cyan") translate([100, 120, -4]) cube([100, 2, 2]);
// Sides
difference() {
color("green") translate([0, 0, 0]) linear_extrude(4) polygon(polyRound(points, 30));
translate([13, -10, -4]) cube([277, 200, 10]);
}
}
// Holes for stems
for ( x = [0:11], y = [0:3] ) {
translate([x*19+38+7, y*19+3+7, -6])
cylinder(h=14, d=5, center=true);
}
// Well for screw shank
translate([9, 10, 2]) rotate([0, 90, 0]) cylinder(h=6.1+2, d=screw_shank_diameter, center=true);
translate([9, 90, 2]) rotate([0, 90, 0]) cylinder(h=6.1+2, d=screw_shank_diameter, center=true);
translate([290.01, 10, 2]) rotate([0, 90, 0]) cylinder(h=6.1+2, d=screw_shank_diameter, center=true);
translate([290.01, 90, 2]) rotate([0, 90, 0]) cylinder(h=6.1+2, d=screw_shank_diameter, center=true);
}
}
if (parts[0]) {
translate([-10, 0, 0]) difference() {
rotate([0, 0, 0]) translate([-160, -100, 0]) keyboard();
partition_mask(w=350, l=45, cutpath="dovetail", cutsize=5, spin=90, inverse=true);
translate([6, -300, -50]) cube([200, 400, 100]);
}
}
if (parts[1]) {
translate([10, 0, 0]) difference() {
rotate([0, 0, 0]) translate([-160, -100, 0]) keyboard();
partition_mask(w=350, l=45, cutpath="dovetail", cutsize=5, spin=90, inverse=false);
translate([-200, -222.4, -50]) cube([206, 200, 100]);
}
}
//keyboard();
/*
for ( x = [0:11], y = [0:3] ) {
translate([x*19+38+7, y*19+3+7, 1]) switch();
}
translate([61, 109, 0]) rotate([0, 0, 0]) pcb(pcbs[5]);
//rotate([0, -90, 0]) screw("M3", head="pan", drive="phillips",length=6);
*/
if (parts[2]) {
translate([-10, 0, -10]) difference() {
rotate([0, 0, 0]) translate([-160, -100, 0]) bottom_plate();
translate([-10, -100, 0]) partition_mask(w=350, l=300, cutpath="dovetail", cutsize=5, spin=90, inverse=true);
}
}
if (parts[3]) {
translate([10, 0, -10]) difference() {
rotate([0, 0, 0]) translate([-160, -100, 0]) bottom_plate();
translate([-10, -100, 0]) partition_mask(w=350, l=300, cutpath="dovetail", cutsize=5, spin=90, inverse=false);
}
}
module switch() {
translate([0, 0, 3.6])
rotate([90, 00, -90])
import("Kailh_PG1353.stl");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment