Skip to content

Commit

Permalink
Merge pull request SolidCode#14 from karel1980/master
Browse files Browse the repository at this point in the history
Capture MCAD work by karel1980
  • Loading branch information
McNeight committed Mar 31, 2014
2 parents 27a309d + da49a8e commit fb20a2c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
55 changes: 26 additions & 29 deletions bitmap/name_tag.scad
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@ http://creativecommons.org/licenses/by/3.0/

use <bitmap.scad>

// change chars array and char_count
// OpenSCAD has no string or length methods :(
chars = ["R", "E", "P", "R", "A", "P"];
char_count = 6;


// block size 1 will result in 8mm per letter
block_size = 2;
// height is the Z height of each letter
height = 3;
// Append a hole fo a keyring, necklace etc. ?
key_ring_hole = true;

union() {
translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) {
8bit_str(chars, char_count, block_size, height);
}
translate(v = [0,0,3/2]) {
color([0,0,1,1]) {
cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true);
}
}
if (key_ring_hole == true){
translate([0, block_size * 8 * (char_count+1)/2, 3/2])
difference(){
cube(size = [block_size * 8, block_size * 8 , 3], center = true);
cube(size = [block_size * 4, block_size * 4 , 5], center = true);
}
}
/*
chars = chars array
block_size = letter size (block size 1 will result in 8mm per letter)
height = the Z height of each letter in mm
key_ring_hole = (boolean) Append a hole to a keyring, necklace etc. ?
*/
module name_tag(chars = ["R", "E", "P", "R", "A", "P"],
block_size = 2, height = 3, key_ring_hole = true) {
char_count = len(chars);
union() {
translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) {
8bit_str(chars, char_count, block_size, height);
}
translate(v = [0,0,3/2]) {
color([0,0,1,1]) {
cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true);
}
}
if (key_ring_hole == true){
translate([0, block_size * 8 * (char_count+1)/2, 3/2])
difference(){
cube(size = [block_size * 8, block_size * 8 , 3], center = true);
cube(size = [block_size * 4, block_size * 4 , 5], center = true);
}
}
}
}
19 changes: 19 additions & 0 deletions bitmap/test_name_tag.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include <../bitmap/name_tag.scad>;

translate([0,0,0])
name_tag("name_tag");

translate([20,0,0]) // 0 + 16/2 + 16/2 + 4
name_tag("NAME_TAG");

translate([52,0,0]) // 20 + 16/2 + 40/2 + 4
name_tag("name_tag", block_size=5);

translate([96,0,0]) // 52 + 40/2 + 40/2 + 4
name_tag("NAME_TAG", block_size=5);

translate([130,0,0]) // 92 + 40/2 + 16/2 + 4
name_tag("name_tag", height=30);

translate([150,0,0]) // 130 + 16/2 + 16/2 + 4
name_tag("NAME_TAG", height=30);

0 comments on commit fb20a2c

Please sign in to comment.