forked from kekstee/3dprint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathyoda.scad
106 lines (89 loc) · 2.49 KB
/
yoda.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
fudge = 0.1;
// Row 4 decorated Cherry MX key
// dimensions Cherry MX connector
c_corr = .1; // tolerance
c_horiz = 1.1; // horizontal bar width
c_vert = 1.0; // vertical bar width
c_dia = 4; // cross width
c_depth = 4.5; // connector depth
c_space = 4; // height of hollow inside
c_inset = .75; // distance connector start to keycap base
//cut out size
cut_h=9;
cut_x=1.4;
cut_y=1;
// keycap shape
head_tilt = 3; // rotation of top around x-axis
head_pos = 2.25; // keycap top y-offset
head_height = 11; // z-offset of keycap top from the bottom of the keycap
cutoff = 6.5; // cut keycap here to make room for decoration
// must be bigger than c_space + c_corr
key_scale = [1.0,1.00,1.00]; // overall scale
// stuff
$fn = 64;
// create basic key shape from dxf frames for base and top
module shape()
{
hull()
{
translate([0,0,-c_inset]) linear_extrude(height=.01) import("base.dxf");
rotate([head_tilt,0,0]) translate([0,6.75+head_pos,head_height-c_inset]) linear_extrude(height=.01) import("top.dxf");
}
}
// construct the connector pin
module connector()
{
translate([0,0,c_depth/2-.1]) union()
{
cube([c_vert+c_corr,c_dia+c_corr,c_depth+.1], center=true );
cube([c_dia+c_corr,c_horiz+c_corr,c_depth+.1], center=true );
}
}
module yoda()
{
import("Yoda-Lite.stl");
}
// create the hollow key with decoration
module key()
{
difference()
{
// combine basic key shape with decoration
union()
{
difference()
{
shape();
rotate([head_tilt,0,0]) translate([0,0,5+cutoff-c_inset]) cube([100,100,10], center=true);
}
}
// subtract scaled basic shape, cut at minimum required height
difference()
{
scale([.9,.9,.9]) translate([0,0,-1]) shape();
translate([0,0,5+c_space+c_corr]) cube([100,100,10], center=true);
}
}
}
// combine key, pin and connector. cleanup below the key
scale(key_scale) difference()
{
union()
{
scale([0.25,0.25,0.25])
yoda();
translate([0,0,-3.5])
rotate([0,0,35])
difference()
{
cylinder( h=c_space+c_corr, r=(c_dia+c_corr+1.5)/2 );
connector();
}
}
//union()
//{
//cylinder( h=c_space+c_corr, r=(c_dia+c_corr+1.5)/2 );
//}
//connector();
//translate([0,0,-50-c_inset]) cube([100,100,100], center=true);
}