-
Notifications
You must be signed in to change notification settings - Fork 8
/
demo.scad
112 lines (89 loc) · 2.6 KB
/
demo.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
include <boxmaker.scad>;
// Box inner dimensions
box_inner = [100, 70, 50];
// Material thickness (mm)
thickness = 3;
// Tab width (X, Y, Z, TopX, TopY) (mm)
// The TopX and TopY here create a nice easy-to-open lid.
tabs_with_lid = [7, 7, 7, box_inner[0]/3, box_inner[1]/3];
box_with_lid(box_inner, thickness, tabs_with_lid);
// When there's no top, leave off the last two dimensions
// Tab width (X, Y, Z) (mm)
tabs_no_top = [7, 7, 7];
translate([box_inner[0] + 20, 0, 0])
box_without_top(box_inner, thickness, tabs_no_top);
module box_with_lid(box_inner, thickness, tabs) {
// Due to the limitations of OpenSCAD, the best way to allow for the same
// geometry to be used in both the 3D and 2D previews is to comment /
// uncomment portions of the code. Please comment/uncomment the appropriate
// BEGIN/END sections below.
// BEGIN 2D LAYOUT
//layout_2d(box_inner, thickness) {
// END 2D LAYOUT
// BEGIN 3D PREVIEW
color("black") cube(box_inner); layout_3d(box_inner, thickness) {
// END 3D PREVIEW
difference() {
side_a_top(box_inner, thickness, tabs);
text("top");
translate([box_inner[0] / 2, box_inner[1] / 2])
circle(r=10);
}
difference() {
side_a(box_inner, thickness, tabs);
text("bottom");
}
difference() {
side_b(box_inner, thickness, tabs);
text("left");
}
difference() {
side_b(box_inner, thickness, tabs);
text("right");
}
difference() {
side_c(box_inner, thickness, tabs);
text("front");
}
difference() {
side_c(box_inner, thickness, tabs);
text("back");
}
}
}
module box_without_top(box_inner, thickness, tabs) {
// Due to the limitations of OpenSCAD, the best way to allow for the same
// geometry to be used in both the 3D and 2D previews is to comment /
// uncomment portions of the code. Please comment/uncomment the appropriate
// BEGIN/END sections below.
// BEGIN 2D LAYOUT
//layout_2d(box_inner, thickness) {
// END 2D LAYOUT
// BEGIN 3D PREVIEW
color("black") cube(box_inner); layout_3d(box_inner, thickness) {
// END 3D PREVIEW
// put this here to leave the lid off
// Top
empty();
difference() {
side_a(box_inner, thickness, tabs);
text("bottom");
}
difference() {
side_b(box_inner, thickness, tabs);
text("left");
}
difference() {
side_b(box_inner, thickness, tabs);
text("right");
}
difference() {
side_c(box_inner, thickness, tabs);
text("front");
}
difference() {
side_c(box_inner, thickness, tabs);
text("back");
}
}
}