-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathserial_number_panel.scad
52 lines (44 loc) · 1.21 KB
/
serial_number_panel.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
//A lasercutter plate for a batch_run with serial number strings
include <Metamaquina2.h>;
include <PowerSupply.h>;
module serial_number_plate(){
assign(revision_id = batch_run[0],
batch_number = batch_run[1],
first_id = batch_run[2],
size_of_batch = batch_run[3]){
for (i=[0:size_of_batch-1]){
translate([7*(i%2), i*52])
face_with_serial_number(revision_id, batch_number, first_id+i);
}
}
}
module glyph(char, fontsize){
scale(fontsize/12){
import("font.dxf", layer=char);
}
}
module draw_number(value, digits, spacing=0.7, fontsize=7){
string = str(value + pow(10,digits));
text_length = (len(string)+1) * spacing*fontsize;
translate([- text_length/2, fontsize/3]){
for (i=[0:digits-1]){
translate([spacing*fontsize*i,0])
if (i+1<len(string))
glyph(string[i+1], fontsize);
else
glyph("0", fontsize);
}
}
}
module face_with_serial_number(revision_id, batch_number, id){
difference(){
PowerSupplyBox_bottom_face();
translate([30,15])
import("serial_number_template.dxf");
translate([45,13])
draw_number(batch_number, 2);
translate([64,13])
draw_number(id, 4);
}
}
serial_number_plate();