-
Notifications
You must be signed in to change notification settings - Fork 13
/
ScatolaArrotondataParametrica.scad
119 lines (107 loc) · 3.3 KB
/
ScatolaArrotondataParametrica.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
altezza = 35;
larghezza = 65;
profondita = 85;
arrotondamento = 12;
module scatola(){
translate([0,0,altezza/2]){
difference(){
roundedBox([larghezza,profondita,altezza], arrotondamento, true);
translate([0,0,2]){
roundedBox([larghezza-3,profondita-3,altezza+2], arrotondamento, true);
}
}
}
}
module coperchio(){
translate([0,0,altezza]){
roundedBox([larghezza-3,profondita-3,2], arrotondamento, true);
translate([0,0,2]){
roundedBox([larghezza,profondita,2], arrotondamento, true);
}
}
}
module roundedBox(size, radius, sidesonly)
{
rot = [ [0,0,0], [90,0,90], [90,90,0] ];
if (sidesonly) {
cube(size - [2*radius,0,0], true);
cube(size - [0,2*radius,0], true);
for (x = [radius-size[0]/2, -radius+size[0]/2],
y = [radius-size[1]/2, -radius+size[1]/2]) {
translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);
}
}
else {
cube([size[0], size[1]-radius*2, size[2]-radius*2], center=true);
cube([size[0]-radius*2, size[1], size[2]-radius*2], center=true);
cube([size[0]-radius*2, size[1]-radius*2, size[2]], center=true);
for (axis = [0:2]) {
for (x = [radius-size[axis]/2, -radius+size[axis]/2],
y = [radius-size[(axis+1)%3]/2, -radius+size[(axis+1)%3]/2]) {
rotate(rot[axis])
translate([x,y,0])
cylinder(h=size[(axis+2)%3]-2*radius, r=radius, center=true);
}
}
for (x = [radius-size[0]/2, -radius+size[0]/2],
y = [radius-size[1]/2, -radius+size[1]/2],
z = [radius-size[2]/2, -radius+size[2]/2]) {
translate([x,y,z]) sphere(radius);
}
}
}
scatola();
coperchio(); = 35;
larghezza = 65;
profondita = 85;
arrotondamento = 12;
module scatola(){
translate([0,0,altezza/2]){
difference(){
roundedBox([larghezza,profondita,altezza], arrotondamento, true);
translate([0,0,2]){
roundedBox([larghezza-3,profondita-3,altezza+2], arrotondamento, true);
}
}
}
}
module coperchio(){
translate([0,0,altezza]){
roundedBox([larghezza-3,profondita-3,2], arrotondamento, true);
translate([0,0,2]){
roundedBox([larghezza,profondita,2], arrotondamento, true);
}
}
}
module roundedBox(size, radius, sidesonly)
{
rot = [ [0,0,0], [90,0,90], [90,90,0] ];
if (sidesonly) {
cube(size - [2*radius,0,0], true);
cube(size - [0,2*radius,0], true);
for (x = [radius-size[0]/2, -radius+size[0]/2],
y = [radius-size[1]/2, -radius+size[1]/2]) {
translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);
}
}
else {
cube([size[0], size[1]-radius*2, size[2]-radius*2], center=true);
cube([size[0]-radius*2, size[1], size[2]-radius*2], center=true);
cube([size[0]-radius*2, size[1]-radius*2, size[2]], center=true);
for (axis = [0:2]) {
for (x = [radius-size[axis]/2, -radius+size[axis]/2],
y = [radius-size[(axis+1)%3]/2, -radius+size[(axis+1)%3]/2]) {
rotate(rot[axis])
translate([x,y,0])
cylinder(h=size[(axis+2)%3]-2*radius, r=radius, center=true);
}
}
for (x = [radius-size[0]/2, -radius+size[0]/2],
y = [radius-size[1]/2, -radius+size[1]/2],
z = [radius-size[2]/2, -radius+size[2]/2]) {
translate([x,y,z]) sphere(radius);
}
}
}
scatola();
coperchio();