Skip to content

Commit fb20a2c

Browse files
committed
Merge pull request SolidCode#14 from karel1980/master
Capture MCAD work by karel1980
2 parents 27a309d + da49a8e commit fb20a2c

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

bitmap/name_tag.scad

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,30 @@ http://creativecommons.org/licenses/by/3.0/
77

88
use <bitmap.scad>
99

10-
// change chars array and char_count
11-
// OpenSCAD has no string or length methods :(
12-
chars = ["R", "E", "P", "R", "A", "P"];
13-
char_count = 6;
14-
15-
16-
// block size 1 will result in 8mm per letter
17-
block_size = 2;
18-
// height is the Z height of each letter
19-
height = 3;
20-
// Append a hole fo a keyring, necklace etc. ?
21-
key_ring_hole = true;
22-
23-
union() {
24-
translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) {
25-
8bit_str(chars, char_count, block_size, height);
26-
}
27-
translate(v = [0,0,3/2]) {
28-
color([0,0,1,1]) {
29-
cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true);
30-
}
31-
}
32-
if (key_ring_hole == true){
33-
translate([0, block_size * 8 * (char_count+1)/2, 3/2])
34-
difference(){
35-
cube(size = [block_size * 8, block_size * 8 , 3], center = true);
36-
cube(size = [block_size * 4, block_size * 4 , 5], center = true);
37-
}
38-
}
10+
/*
11+
chars = chars array
12+
block_size = letter size (block size 1 will result in 8mm per letter)
13+
height = the Z height of each letter in mm
14+
key_ring_hole = (boolean) Append a hole to a keyring, necklace etc. ?
15+
*/
16+
module name_tag(chars = ["R", "E", "P", "R", "A", "P"],
17+
block_size = 2, height = 3, key_ring_hole = true) {
18+
char_count = len(chars);
19+
union() {
20+
translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) {
21+
8bit_str(chars, char_count, block_size, height);
22+
}
23+
translate(v = [0,0,3/2]) {
24+
color([0,0,1,1]) {
25+
cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true);
26+
}
27+
}
28+
if (key_ring_hole == true){
29+
translate([0, block_size * 8 * (char_count+1)/2, 3/2])
30+
difference(){
31+
cube(size = [block_size * 8, block_size * 8 , 3], center = true);
32+
cube(size = [block_size * 4, block_size * 4 , 5], center = true);
33+
}
34+
}
35+
}
3936
}

bitmap/test_name_tag.scad

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include <../bitmap/name_tag.scad>;
2+
3+
translate([0,0,0])
4+
name_tag("name_tag");
5+
6+
translate([20,0,0]) // 0 + 16/2 + 16/2 + 4
7+
name_tag("NAME_TAG");
8+
9+
translate([52,0,0]) // 20 + 16/2 + 40/2 + 4
10+
name_tag("name_tag", block_size=5);
11+
12+
translate([96,0,0]) // 52 + 40/2 + 40/2 + 4
13+
name_tag("NAME_TAG", block_size=5);
14+
15+
translate([130,0,0]) // 92 + 40/2 + 16/2 + 4
16+
name_tag("name_tag", height=30);
17+
18+
translate([150,0,0]) // 130 + 16/2 + 16/2 + 4
19+
name_tag("NAME_TAG", height=30);

0 commit comments

Comments
 (0)