forked from jcrocholl/25000
-
Notifications
You must be signed in to change notification settings - Fork 5
/
outside.jscad
99 lines (96 loc) · 4.27 KB
/
outside.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
function getParameterDefinitions() {
return [
{name: 'frame_height', initial: 75, type: 'float', caption: 'Total height:', size: 5},
{name: 'frame_width', initial: 150, type: 'float', caption: 'Total width:', size: 5},
{name: 'middle_width', initial: 50, type: 'float', caption: 'Mid-section width:', size: 5},
{name: 'extrusion_width', initial: 15, type: 'float', caption: 'Extrusion width:', size: 5},
{name: 'extrusion_screw_diameter', initial: 3.3, type: 'float', caption: 'Extrusion screw size:', size: 5},
{name: 'motor_screw_diameter', initial: 3.3, type: 'float', caption: 'Motor screw size:', size: 5},
{name: 'motor_screw_grid', initial: 31, type: 'float', caption: 'Motor screw grid:', size: 5},
{name: 'motor_cutout_diameter', initial: 23, type: 'float', caption: 'Motor cutout dia:', size: 5},
{name: 'roundness', initial: 4, type: 'float', caption: 'Roundness radius:', size: 5},
{name: 'resolution', initial: 24, type: 'float', caption: 'Resolution:', size: 5}
];
}
function motor(params) {
var result = CAG.circle({
radius: params.motor_cutout_diameter/2,
resolution: params.resolution*2});
var grid = params.motor_screw_grid;
for (var x = -grid/2; x < grid; x = x + grid) {
for (var y = -grid/2; y < grid; y = y + grid) {
result = result.union(CAG.circle({
center: [x, y], radius: params.motor_screw_diameter/2,
resolution: params.resolution}));
}
}
return result;
}
function panel(params) {
var result = CAG.rectangle({
radius: [params.frame_width/2 - params.extrusion_width/2,
params.frame_height/2]});
var cutout_x = params.frame_width - params.extrusion_width;
for (var x = -cutout_x/2; x < cutout_x; x = x + cutout_x) {
result = result.subtract(CAG.circle({
center: [x, 0],
radius: params.frame_height/2 - params.extrusion_width,
resolution: params.resolution*4}));
}
var offset_x = params.frame_width - params.extrusion_width;
var offset_y = params.frame_height - params.extrusion_width;
for (var y = -offset_y/2; y < offset_y; y = y + offset_y) {
result = result.union(CAG.roundedRectangle({
center: [0, y],
radius: [params.frame_width/2, params.extrusion_width/2],
roundradius: params.roundness,
resolution: params.resolution}));
result = result.subtract(CAG.circle({
center: [0, y],
radius: params.extrusion_screw_diameter/2,
resolution: params.resolution}));
for (x = -offset_x/2; x < offset_x; x = x + offset_x) {
result = result.subtract(CAG.circle({
center: [x, y],
radius: params.extrusion_screw_diameter/2,
resolution: params.resolution}));
result = result.subtract(CAG.circle({
center: [x/2, y],
radius: params.extrusion_screw_diameter/2,
resolution: params.resolution}));
}
for (x = -15; x < 30; x = x + 30) {
result = result.subtract(CAG.circle({
center: [x, y],
radius: params.extrusion_screw_diameter/2,
resolution: params.resolution}));
}
}
// Dents for bending lines.
offset_x = params.middle_width;
offset_y = params.frame_height + 1;
for (y = -offset_y/2; y < offset_y; y = y + offset_y) {
for (x = -offset_x/2; x < offset_x; x = x + offset_x) {
result = result.subtract(CAG.circle({
center: [x, y],
radius: params.extrusion_screw_diameter/2,
resolution: params.resolution}));
}
}
// M5 holes for 2040 extrusion (e.g. V-Slot).
offset_x = 20;
offset_y = params.frame_height - 30;
for (y = -offset_y/2; y < offset_y; y = y + offset_y) {
for (x = -offset_x/2; x < offset_x/2+1; x = x + offset_x/2) {
result = result.subtract(CAG.circle({
center: [x, y],
radius: 5.5/2,
resolution: params.resolution*2}));
}
}
result = result.subtract(motor(params));
return result;
}
function main(params) {
return panel(params);
}