-
Notifications
You must be signed in to change notification settings - Fork 1
/
punto-windows-switch.jscad
103 lines (94 loc) · 2.64 KB
/
punto-windows-switch.jscad
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
//
// Electric window fix for Punto
//
//include ('jscad-utils.jscad')
//include ('jscad-utils-color.jscad')
function getParameterDefinitions() {
return [{
name: 'resolution',
type: 'choice',
values: [0, 1, 2, 3, 4, 5],
captions: ['very low (6,16)', 'low (8,24)', 'normal (12,32)', 'high (24,64)', 'very high (48,128)',
'ultra high (96,256)'],
initial: 2,
caption: 'Resolution:'
}, {
name: 'part',
type: 'choice',
values: ['left', 'right'],
captions: ['left window switch', 'right window switch'],
initial: 'left',
caption: 'Part:'
}];
}
function main(params) {
var resolutions = [
[6, 16],
[8, 24],
[12, 32],
[24, 64],
[48, 128],
[96, 256]
];
CSG.defaultResolution3D = resolutions[params.resolution][0];
CSG.defaultResolution2D = resolutions[params.resolution][1];
//util.init(CSG);
// Radius of part
var base_l = 13.8;
var base_w = 13.4;
var thickness = 1.0;
// Height of (half) part
var base_h = 6.4;
var axis_l = 4.7/2;
var axis_r1 = 1.9/2;
var axis_r2 = 2.9/2;
var pin_h_l1 = 1.5;
var pin_h_l2 = 1.5;
var pin_h_r1 = 1.5;
var pin_h_r2 = 1;
var pin_w = 1.5;
var pin_l = 2/2;
var pin_r1 = 1/2;
var pin_r2 = 1/2;
var [pin_h1, pin_h2] = (params.part == 'left') ? [pin_h_l1, pin_h_l2] : [pin_h_r1, pin_h_r2];
var axis1 = CSG.cylinder({
start: [0,0,0],
end: [0, 0, axis_l+thickness/2],
radius: axis_r1
});
var axis2 = CSG.cylinder({
start: [0,0,0],
end: [0, 0, axis_l+thickness/2],
radius: axis_r2
});
// Hold part in place using drilled holes in the original switch
var pin1 = CSG.cylinder({
start: [0,0,0],
end: [0, 0, pin_l+thickness/2],
radius: pin_r1
});
var pin2 = CSG.cylinder({
start: [0,0,0],
end: [0, 0, pin_l+thickness/2],
radius: pin_r2
});
var piece =
CSG.cube ({radius: [base_w/2, base_l/2, base_h/2]})
.subtract(CSG.cube ({radius: [base_w/2-thickness, base_l/2-thickness, base_h/2]}))
.subtract(pin1.rotateX(90).translate([-(base_w/2-pin_w), -(base_l/2-thickness), pin_h1-base_h/2]))
.subtract(pin2.rotateX(-90).translate([-(base_w/2-pin_w), (base_l/2-thickness), pin_h2-base_h/2]))
.union(axis1.rotateX(90).translate([0, -(base_l/2-thickness/2), base_h/2-axis_r1]))
.union(axis2.rotateX(-90).translate([0, (base_l/2-thickness/2), base_h/2-axis_r1]))
.rotateX(180)
.intersect(CSG.cube ({radius: [base_w/2, base_l/2+axis_l, base_h/2]}))
//.subtract(CSG.cube ({radius: [base_w/2, 1, base_h/2]}).translate([-base_w/2, 0, 0]))
;
//
// Render
//
switch (params.part) {
case 'left':
case 'right':
}
return piece;
}