-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorner.scad
211 lines (174 loc) · 6.65 KB
/
corner.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
use <string.scad>;
use <MQR-code.scad>;
/* [Shapes] */
edge_shape = "rectangular"; // [rectangular, circular, sphere]
edge_hole_shape = "rectangular"; // [rectangular, circular, none]
// The main hole is usefull if you want a mobile construction
main_hole_shape = "none"; // [rectangular, circular, none]
// The main shape of your corner.
shape = "Personalised"; // [Extremity, I, T, L, X, Cube_corner, T_corner, Half_star, Star, Tetrahedron_corner, Octahedron_corner, Personalised]
// On several shapes, you can change the number of members.
edges_number = 1; // [0:min, 1:medium, 2:max]
// In case of a personalised part, set here the part members angles, by pairs of vertical angle and horizontal angle.
angles = "090,180,090,225,090,270,000,090";
/* [Dimentions] */
// width of the part.
width = 7.5;
// Set 0 if you want than edge length equals Width.
edge_length = 14;
// Edges hole width size.
hole_width = 4.5;
// Set 0 if you want than edge length equals Width.
hole_deep = 8.5;
// Difference between the main hole size and the edges hole size.
main_hole_slack = 0.2;
/* [Clip] */
// This clip allows you to hold the rods on the plastic part.
clip_type = "hole"; // [none, hole]
clip_width = 2;
clip_position = 4;
/* [Bevel] */
edge_bevel = "none"; // [none, thin, medium, large, sphere]
external_bevel = "sphere"; // [none, sphere]
holes_bevel = "none"; // [none, thin, medium, large]
/* [Hidden] */
id = 12345;
notch_size = 1.5;
code = false;
/* Here is the serious stuff */
pos=[0,0,0];
translate(pos) print_parts(shape);
module print_parts(part)
{
if (part == "Extremity")
part([[90,0]]);
else if (part == "I")
part([[90,0], [90,180]]);
else if (part == "T")
if (edges_number == 0)
part([[90,0], [90,90], [90,180]]);
else
part([[90,0], [90,45], [90,90], [90,135], [90,180]]);
else if (part == "L")
if (edges_number == 0)
part([[90,0], [90,90]]);
else
part([[90,0], [90,45], [90,90]]);
else if (part == "X")
if (edges_number == 0)
part([[90,0], [90,90], [90,180], [90,270]]);
else
part([[90,0], [90,45], [90,90], [90,135], [90,180], [90,225], [90,270], [90,315]]);
else if (part == "Cube_corner")
if (edges_number == 0)
part([[0,0],[90,0],[90,90]]);
else if (edges_number == 1)
part([[0,0],[45,0],[90,0],[45,90],[90,90]]);
else
part([[0,0],[45,0],[90,0],[45,90],[90,90],[90,45]]);
else if (part == "T_corner")
if (edges_number == 0)
part([[0,0],[90,0],[90,90],[90,180]]);
else if (edges_number == 1)
part([[0,0],[45, 0],[90,0],[45,90],[90,90],[45,180],[90,180]]);
else
part([[0,0],[45, 0],[90,0],[45,90],[90,90],[45,180],[90,180],[90,45],[90,135]]);
else if (part == "Half_star")
if (edges_number == 0)
part([[0,0],[90,0],[90,90],[90,180],[90,270]]);
else if (edges_number == 1)
part([[0,0],[45,0],[90,0],[45,90],[90,90],[45,180],[90,180],[90,270],[45,270]]);
else
part([[0,0],[45,0],[90,0],[45,90],[90,90],[45,180],[90,180],[90,45],[90,135],[90,270],[45,270],[90,225],[90,315]]);
else if (part == "Star")
if (edges_number == 0)
part([[0,0],[90,0],[90,90],[90,180],[90,270],[180,0]]);
else if (edges_number == 1)
part([[0,0],[45,0],[90,0],[45,90],[90,90],[45,180],[90,180],[90,270],[45,270],[180,0],[135,0],[135,90],[135,180],[135,270]]);
else
part([[0,0],[45,0],[90,0],[45,90],[90,90],[45,180],[90,180],[90,45],[90,135],[90,270],[45,270],[90,225],[90,315],[180,0],[135,0],[135,90],[135,180],[135,270]]);
else if (part == "Tetrahedron_corner")
part([[35.26,0],[35.26,120],[35.26,240]]); // acos(sqrt(6)/3)
else if (part == "Octahedron_corner")
part([[45,0],[45,90],[45,180],[45,270]]); // acos(sqrt(2)/2)
else if (part == "Personalised")
part([[d(0),d(1)],[d(2),d(3)],[d(4),d(5)],[d(6),d(7)],[d(8),d(9)],[d(10),d(11)]]);
}
module part(v)
{
$fn = 50;
edge_length = (edge_length < width) ? width : edge_length;
hole_width = (hole_width >= width) ? width-1 : hole_width;
main_hole_width = hole_width + main_hole_slack;
hole_deep = (hole_deep <=0) ? edge_length : hole_deep;
intersection() {
if (external_bevel == "sphere")
sphere(edge_length);
difference() {
if (edge_shape == "sphere") {
sphere(edge_length);
} else {
union() {
sphere(width/2);
for(i = [0:len(v)-1]) {
if (v[i][0] != -1)
rotate([v[i][0], 0, v[i][1]])
translate([0,0,-width/8]) intersection() {
cylinder(r1=width/2-width/64, r2=width, h=edge_length+width/8);
block(width, edge_length+width/2, edge_shape, bevel = "ext");
}
}
}
}
for(i = [0:len(v)-1]) {
if (v[i][0] != -1)
rotate([v[i][0], 0, v[i][1]]) {
translate([0, 0, edge_length - hole_deep + 0.1])
block(hole_width, hole_deep, edge_hole_shape, bevel = "int");
translate([hole_width/4, -notch_size/2, edge_length-notch_size*0.6])
cube([width/2, notch_size, notch_size]);
if (clip_type == "hole") {
translate([0, 0.5, edge_length-hole_deep+clip_position+1]) rotate([90,0,0]) translate([0, 0, -width/2])
cylinder(r=clip_width/2, h=width+1);
}
}
}
block(main_hole_width, width+1, main_hole_shape);
}
}
if (code == true)
translate([0,0,width/2])
for(i = [0:len(v)-1])
if (v[i][0] != -1)
rotate([v[i][0], 0, v[i][1]])
translate([-hole_width/2, -hole_width/2, edge_length-hole_deep-0.1])
mqr_code(id, hole_width, 4);
}
module block(block_width, length, shape, bevel)
{
ext_bevel = bevel(edge_bevel, block_width)/2;
int_bevel = bevel(holes_bevel, hole_width)*1.5;
length = (length == 0) ? width : length;
translate ([0, 0, length/2-0.1]) /*intersection()*/ {
union() {
if (shape=="rectangular")
cube([block_width, block_width, length], center=true);
else if (shape=="circular")
cylinder(r=block_width/2, h=length, center=true);
else if (shape=="hexagonal")
rotate([0,0,22.5]) cylinder(r=block_width/2, h=length, center=true, $fn=8);
if (bevel == "int")
translate([0, 0, length/2 - block_width/2]) rotate([0,0,45])
cylinder(r1=0, r2 = (edge_hole_shape == "rectangular") ? block_width*0.707 + int_bevel : block_width/2 + int_bevel, h=block_width/2, $fn = (edge_hole_shape == "rectangular") ? 4 : $fn);
}
/*union() {
if (bevel == "ext") {
translate([0, 0, length*1.5 - block_width*0.28 - ext_bevel]) rotate([180,0,45])
cylinder(r1=0, r2 = block_width+0.1, h=block_width+0.1, $fn = (edge_hole_shape == "rectangular") ? 4 : $fn);
translate([0, 0, -length/2]) cube([block_width+0.1, block_width+0.1, length*1.5+0.1], center=true);
}
}*/
}
}
function bevel(type, ref) = (type == "thin") ? ref*0.2 : (type == "medium") ? ref*0.3 : (type == "large") ? ref*0.6 : 0;
function d(i) = (strToInt(getsplit(angles, i, ",")) == undef) ? -1 : strToInt(getsplit(angles, i, ","));