-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmf.scad
80 lines (72 loc) · 2.07 KB
/
mf.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
include <gridfinity-rebuilt-openscad/src/core/gridfinity-rebuilt-utility.scad>
include <key.scad/key.scad>
include <stem.scad>
$fa = 8;
$fs = 0.25; // .01
//$fa = 0.01;
//$fs = 0.01; // .01
scale = 0.42;
// spacing between key centers (X-axis)
kx = U;
// spacing between key centers (Y-axis)
ky = U;
// keycap width (cherry: 18, choc: 17.5)
keycw = BASE_TOP_DIMENSIONS.x*scale;
// keycap height (cherry: 18, choc: 16.5)
keych = BASE_TOP_DIMENSIONS.y*scale;
size = [1, 1];
supported = [mx, choc_v2];
housing = [
max([for(sw=supported)housing(sw).x]),
max([for(sw=supported)housing(sw).y]),
];
stem = min([for(sw=supported)stem(sw)]);
// keycap Z-height
h = stem + min([for(sw=supported)height(h(sw),2,1,true)-h(sw)+BASE_HEIGHT]);
// stem diameter
d = 5.5;
// how should the top lip act
style_lip = 0; //[0: Regular lip, 1:remove lip subtractively, 2: remove lip and retain height]
orientation = "down"; // [up: Up, down: Down]
stackable = false;
flip = false;
if (flip)
mirror([0, 0, 1])
main();
else
main();
module main() {
render() difference() {
let (
x = kx*(size.x-1) + keycw,
y = ky*(size.y-1) + keych,
top_dimensions = BASE_TOP_DIMENSIONS
) {
if (orientation == "down")
translate([0, 0, h]) mirror([0, 0, 1])
mf_bin();
else
mf_bin();
}
let (
x = kx*(size.x-1) + housing.x,
y = ky*(size.y-1) + housing.y,
z = orientation == "up" ? stem : h-1.2,
r = 0.5
) {
translate([-x/2+r, -y/2+r, 0])
rounded_square([x, y, z], r);
}
}
render() difference() {
stem(stem, stem, d);
if (orientation != "up" && style_lip != 2 && stackable)
cylinder(h = STACKING_LIP_SIZE.y*scale, d = d);
}
}
module mf_bin() {
scale(scale) {
gridfinityInit(gx = size.x, gy = size.y, h = hf(h/scale-BASE_HEIGHT-STACKING_LIP_SIZE.y,2,style_lip),sl=style_lip);
gridfinityBase(grid_size = [size.x, size.y]);
}
}