forked from kekstee/3dprint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkey_lower_skull.scad
114 lines (98 loc) · 3.04 KB
/
key_lower_skull.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
106
107
108
109
110
111
112
113
114
// Row 4 decorated Cherry MX key
// dimensions Cherry MX connector
c_corr = .2; // tolerance
c_horiz = 1.1; // horizontal bar width
c_vert = 1.0; // vertical bar width
c_dia = 4; // cross width
c_depth = 6; // 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;
// decoration
obj = "skull.stl"; // decoration object
obj_pos = [0,-4,10]; // decoration offset
obj_scale = [1.18,1.1,1.1]; // decoration scale
obj_rot = [40,0,0]; // decoration rotation
// 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.01,1.01,1.01]; // 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 );
}
}
//the cut out for eyes
module ovalTube(height, rx, ry, wall, center = false) {
difference() {
scale([1, ry/rx, 1]) cylinder(h=height, r=rx, center=center);
scale([(rx-wall)/rx, (ry-wall)/rx, 1]) cylinder(h=height, r=rx, center=center);
}
}
//oval tube cutout
module cutout()
{
ovalTube( height=cut_h, rx=cut_x, ry=cut_y, wall=1.4 );
}
// create the hollow key with decoration
module key()
{
difference()
{
// combine basic key shape with decoration
union()
{
translate(obj_pos) rotate(obj_rot) scale(obj_scale) import(obj);
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()
{
key();
cylinder( h=c_space+c_corr, r=(c_dia+c_corr)/2 );
}
connector();
difference(){
// cutout();
translate([3.1,-3.7,0]) cutout();
}
difference(){
translate([-3.1,-3.7,0]) cutout();
}
translate([0,0,-50-c_inset]) cube([100,100,100], center=true);
}