forked from jempe/raspberry_pi_case
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrounded_box.scad
87 lines (74 loc) · 3 KB
/
rounded_box.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
module rounded_box(box_length, box_width, box_height, round_corners_radius)
{
separation = 0;
round_corners_diameter = round_corners_radius * 2;
echo("rounded box dimensions: w=",box_width," l=",box_length," h=",box_height);
translate([round_corners_radius, round_corners_radius, round_corners_radius])
{
union()
{
cube(size = [(box_length + separation - round_corners_diameter), (box_width + separation - round_corners_diameter), (box_height + separation - round_corners_diameter)]);
for(x = [0, 1])
{
for(y = [0, 1])
{
for(z = [0, 1])
{
translate([((box_length + separation - round_corners_diameter) * x), ((box_width + separation - round_corners_diameter) * y), ((box_height + separation - round_corners_diameter) * z)])
{
sphere(r = round_corners_radius);
}
}
}
}
translate([0, (box_width + separation - round_corners_diameter), 0])
{
cube(size = [(box_length + separation - round_corners_diameter), round_corners_radius, (box_height + separation - round_corners_diameter)]);
}
translate([0, -(round_corners_radius), 0])
{
cube(size = [(box_length + separation - round_corners_diameter), round_corners_radius, (box_height + separation - round_corners_diameter)]);
}
translate([-(round_corners_radius), 0, 0])
{
cube(size = [(round_corners_radius), (box_width + separation - round_corners_diameter), (box_height + separation - round_corners_diameter)]);
}
translate([(box_length + separation - round_corners_diameter), 0, 0])
{
cube(size = [(round_corners_radius), (box_width + separation - round_corners_diameter), (box_height + separation - round_corners_diameter)]);
}
translate([0, 0, -(round_corners_radius)])
{
cube(size = [(box_length + separation - round_corners_diameter), (box_width + separation - round_corners_diameter), (round_corners_radius)]);
}
translate([0, 0, (box_height + separation - round_corners_diameter)])
{
cube(size = [(box_length + separation - round_corners_diameter), (box_width + separation - round_corners_diameter), (round_corners_radius)]);
}
for(axis1 = [0, 1])
{
for(axis2 = [0, 1])
{
translate([((box_length + separation - round_corners_diameter) * axis1), ((box_width + separation - round_corners_diameter) * axis2), 0])
{
cylinder(h = (box_height + separation - round_corners_diameter), r = round_corners_radius);
}
translate([((box_length + separation - round_corners_diameter) * axis1), 0, ((box_height + separation - round_corners_diameter) * axis2)])
{
rotate([270, 0 , 0])
{
cylinder(h = (box_width + separation - round_corners_diameter), r = round_corners_radius);
}
}
translate([0, ((box_width + separation - round_corners_diameter) * axis1), ((box_height + separation - round_corners_diameter) * axis2)])
{
rotate([0, 90 , 0])
{
cylinder(h = (box_length + separation - round_corners_diameter), r = round_corners_radius);
}
}
}
}
}
}
}