-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.scad
176 lines (165 loc) · 3.19 KB
/
model.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
/**
* Script to create a foldable text 3d model
*
* Author: Matthias Bock <[email protected]>
* License: GNU GPLv3
*/
include <settings.scad>;
module paper_a4_landscape()
{
translate([
0,
0,
-1.5
])
cube([
a4_landscape_x,
a4_landscape_y,
1
]);
}
module planar_text()
{
translate([
material_x/2,
0,
0
])
linear_extrude(height=1)
text(
text_string,
size = text_size,
font = text_font,
$fn = 200,
valign = "top",
halign = "center"
);
}
module fold_intersection_top()
{
// rotate back to A4 plane
rotate([
-90,
0,
0
])
// extrude intersection to rectangles
linear_extrude(
height = fold_size
)
// generate projection of cut-out text-top
projection()
// rotate intersection into projection plane (xy)
rotate([
90,
0,
0
])
// generate intersection of line and text-top
intersection()
{
// text, aligned to top, extruded to 3d
translate([
material_x / 2,
0,
0
])
linear_extrude(height=1)
{
text(
text_string,
font = text_font,
size = text_size,
valign = "top",
halign = "center"
);
}
// straight line (3d)
cube([
material_x,
1,
1
]);
}
}
module fold_intersection_bottom()
{
// rotate back into paper plane
rotate([
-90,
0,
0
])
// make 3d again
linear_extrude(
height = 2
)
// get rid of font character curves
projection()
// rotate into projection plane
rotate([
90,
0,
0
])
// generate intersection of text and line
intersection()
{
// text, aligned to bottom, extruded to 3d
translate([
material_x / 2,
0,
0
])
linear_extrude(height=1)
{
text(
text_string,
font = text_font,
size = text_size,
valign = "bottom",
halign = "center"
);
}
// straight line (3d)
cube([
material_x,
1,
1
]);
}
}
module text_model()
{
// make a union of text and ligaments
union()
{
color("green")
translate([
0,
material_y/2,
0
])
planar_text();
color("yellow")
{
// move above text
translate([
0,
material_y / 2,
0
])
fold_intersection_top();
// move up, right below text
translate([
0,
material_y / 2 - fold_size - 1,
0
])
fold_intersection_bottom();
}
}
}
color("lightgrey")
paper_a4_landscape();
text_model();