-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlabel_generator.scad
More file actions
191 lines (150 loc) · 4.99 KB
/
Copy pathlabel_generator.scad
File metadata and controls
191 lines (150 loc) · 4.99 KB
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
///////////////////////////////////////////////
// InfinityGrid Label Generator //
// Imports SVG designs onto label bases //
///////////////////////////////////////////////
/* [Label Settings] */
// SVG file to import (export from web app)
svg_file = "example.svg"; // [.svg file]
// Label size units (must match SVG export)
Y_units = 1; // [1, 2, 3]
// Label base color
Label_color = "#000000"; // color
// Content/design color (raised part)
Content_color = "#FFFFFF"; // color
/* [Advanced Settings] */
// Base width (mm)
base_width = 11.5;
// Base height (mm)
base_height = 0.8;
// Corner radius (mm)
corner_radius = 0.9;
// Edge chamfer (mm)
chamfer = 0.2;
// Content extrusion height (mm) - 0.2 for raised, 0.01 for flush
content_height = 0.2;
// Mounting hole diameter (mm)
hole_diameter = 1.5;
/* [Hidden] */
$fs = 0.1;
$fa = 5;
// Calculate label length based on units
function get_length(units) =
(units == 1) ? 35.8 :
(units == 2) ? 77.8 :
(units == 3) ? 119.8 : 35.8;
// SVG dimensions (must match export settings)
function get_svg_width(units) =
(units == 1) ? 34.5 :
(units == 2) ? 69.0 :
(units == 3) ? 103.5 : 34.5;
svg_height = 10.5;
length = get_length(Y_units);
svg_width = get_svg_width(Y_units);
///////////////////////////////////////////////
// MAIN MODULE //
///////////////////////////////////////////////
// Generate the label
label();
module label() {
// Base
color(Label_color) {
difference() {
labelbase(length, base_width, base_height, corner_radius, chamfer);
// Mounting holes at each end
translate([(length - 1) / 2, 0, 0])
cylinder(h = base_height + 1, d = hole_diameter, center = true);
translate([(-length + 1) / 2, 0, 0])
cylinder(h = base_height + 1, d = hole_diameter, center = true);
}
}
// SVG content
color(Content_color) {
translate([0, 0, base_height])
import_svg_centered();
}
}
///////////////////////////////////////////////
// SVG IMPORT MODULE //
///////////////////////////////////////////////
module import_svg_centered() {
// Center the SVG on the label
translate([-svg_width / 2, -svg_height / 2, 0]) {
linear_extrude(height = content_height) {
import(svg_file, center = false);
}
}
}
///////////////////////////////////////////////
// LABEL BASE MODULES //
///////////////////////////////////////////////
module labelbase(length, width, height, radius, champ) {
// Extra perimeter shape (thin border)
translate([(-length - 2) / 2, -5.7 / 2, 0]) {
shape_with_chamfer(length + 2, 5.7, height, 0.2, champ);
}
// Main label shape
translate([(-length) / 2, -width / 2, 0]) {
shape_with_chamfer(length, width, height, radius, champ);
}
}
module shape_with_chamfer(length, width, height, radius, champ) {
// Bottom chamfer
chamfer_layer(length, width, champ, radius, flip = false);
// Main body
translate([0, 0, champ])
rounded_rect(length, width, height - 2 * champ, radius);
// Top chamfer
translate([0, 0, height - champ])
chamfer_layer(length, width, champ, radius, flip = true);
}
module chamfer_layer(length, width, size, radius, flip = false) {
r1 = flip ? radius : radius - size;
r2 = flip ? radius - size : radius;
hull() {
translate([radius, radius, 0])
cylinder(h = size, r1 = r1, r2 = r2);
translate([radius, width - radius, 0])
cylinder(h = size, r1 = r1, r2 = r2);
translate([length - radius, width - radius, 0])
cylinder(h = size, r1 = r1, r2 = r2);
translate([length - radius, radius, 0])
cylinder(h = size, r1 = r1, r2 = r2);
}
}
module rounded_rect(length, width, height, radius) {
hull() {
translate([radius, radius, 0])
cylinder(h = height, r = radius);
translate([radius, width - radius, 0])
cylinder(h = height, r = radius);
translate([length - radius, width - radius, 0])
cylinder(h = height, r = radius);
translate([length - radius, radius, 0])
cylinder(h = height, r = radius);
}
}
///////////////////////////////////////////////
// BATCH EXPORT //
///////////////////////////////////////////////
// To batch export multiple labels:
// 1. Export all your designs as SVG from the web app
// 2. Uncomment the batch_labels module below
// 3. Update the file list
// 4. Render and export as STL
/*
batch_files = [
"label1.svg",
"label2.svg",
"label3.svg"
];
module batch_labels() {
spacing = length + 3;
for (i = [0 : len(batch_files) - 1]) {
translate([0, i * -15, 0]) {
// Temporarily override svg_file
// Note: OpenSCAD doesn't support dynamic file names easily
// You may need to generate separate .scad files for each
}
}
}
*/