diff --git a/AuerNameTag.scad b/AuerNameTag.scad index ca87be8..d83abc0 100644 --- a/AuerNameTag.scad +++ b/AuerNameTag.scad @@ -1,64 +1,96 @@ -name="madex"; -symbolPre=""; -symbolPost=""; -part=3; //[1:base,2:text,3:preview] +name = "madex"; +symbolPre = ""; +symbolPost = ""; +part = 4; //[1:base,2:text,3:preview,4:colorscad_render] - -use <./font/LiberationSans-Bold.ttf>; -use <./font/Symbola_hint.ttf>; -label_thickness= 1.5; +use <./font/LiberationSans-Bold.ttf> +use <./font/Symbola_hint.ttf> +label_thickness = 1.5; font = "Liberation Sans:style=Bold"; -symbolFont="Symbola:style=Regular"; +symbolFont = "Symbola:style=Regular"; font_size = 12; font_offset = 9; $fn = 128; - -module tag() { - linear_extrude(height=10 + label_thickness/2) translate([91.62, 9.25]) { - difference() { union() { - for (a = [0:180:180]) - rotate(v=[0, 0, 1], a=a) { - polygon([[1, 1], [10.9, 2], [10.2, 7.5], [0,4]]); - polygon([[0, 0], [-10.3, 5], [-10.2, 8.1], [-5, 8.3]]); - } +module +tag() +{ + linear_extrude(height = 10 + label_thickness / 2) translate([ 91.62, 9.25 ]) + { + difference() + { + union() + { + for (a = [0:180:180]) + rotate(v = [ 0, 0, 1 ], a = a) + { + polygon( + [ [ 1, 1 ], [ 10.9, 2 ], [ 10.2, 7.5 ], [ 0, 4 ] ]); + polygon([ + [ 0, 0 ], + [ -10.3, 5 ], + [ -10.2, 8.1 ], + [ -5, 8.3 ] + ]); + } } - circle(d=16.1); + circle(d = 16.1); } } - translate([88.7, 9.25, 0]) cube([181, 20, label_thickness], center=true); - translate([157.5, 12.6, 0]) cube([17, 5, 4 + label_thickness/2]); - translate([150.8, 4, 0]) cube([3, 10, 4 + label_thickness/2]); - translate([156.2, 4, 0]) cube([3, 10, 4 + label_thickness/2]); - - translate([2, 1.1, 0]) cube([60, 3, 10 + label_thickness/2]); - translate([2, 15, 0]) cube([60, 3, 10 + label_thickness/2]); - translate([2, 3.6, label_thickness/2]) rotate([0,90,0])cylinder(r=label_thickness,h=60); - translate([2, 15.5, label_thickness/2]) rotate([0,90,0])cylinder(r=label_thickness,h=60); - + translate([ 88.7, 9.25, 0 ]) + cube([ 181, 20, label_thickness ], center = true); + translate([ 157.5, 12.6, 0 ]) cube([ 17, 5, 4 + label_thickness / 2 ]); + translate([ 150.8, 4, 0 ]) cube([ 3, 10, 4 + label_thickness / 2 ]); + translate([ 156.2, 4, 0 ]) cube([ 3, 10, 4 + label_thickness / 2 ]); + + translate([ 2, 1.1, 0 ]) cube([ 60, 3, 10 + label_thickness / 2 ]); + translate([ 2, 15, 0 ]) cube([ 60, 3, 10 + label_thickness / 2 ]); + translate([ 2, 3.6, label_thickness / 2 ]) rotate([ 0, 90, 0 ]) + cylinder(r = label_thickness, h = 60); + translate([ 2, 15.5, label_thickness / 2 ]) rotate([ 0, 90, 0 ]) + cylinder(r = label_thickness, h = 60); } -module name(str) { - translate([-9+15, font_offset + font_size/2, -label_thickness/2 + 0.29]) rotate(v=[1,0,0],a=180) linear_extrude(0.3) { - text(symbolPre,font_size,symbolFont); - symbolPreSize=textmetrics(symbolPre,font_size,font); - echo (symbolPreSize); - - translate([symbolPreSize.size[0]+symbolPreSize.advance[0],0,0]){ - text(str, size=font_size, font = font); - +module name(str) +{ + translate( + [ -9 + 15, font_offset + font_size / 2, -label_thickness / 2 + 0.29 ]) + rotate(v = [ 1, 0, 0 ], a = 180) linear_extrude(0.3) + { + text(symbolPre, font_size, symbolFont); + symbolPreSize = textmetrics(symbolPre, font_size, font); + echo(symbolPreSize); + + translate([ symbolPreSize.size[0] + symbolPreSize.advance[0], 0, 0 ]) + { + text(str, size = font_size, font = font); + echo(textSize); - - translate([textSize.advance[0],0,0]) text(symbolPost,font_size,symbolFont); + + translate([ textSize.advance[0], 0, 0 ]) + text(symbolPost, font_size, symbolFont); } - textSize=textmetrics(str, size=font_size, font = font); - - } + textSize = textmetrics(str, size = font_size, font = font); + } } - - -difference() { -if(part==1)tag(); -color("black")name(name); +if (part < 4) { + difference() + { + if (part == 1) + tag(); + color("black") name(name); + } + if (part == 3) + difference() + { + color("limegreen") tag(); + color("black") name(name); + } +} else { + color("limegreen") difference() + { + tag(); + name(name); + } + color("black") name(name); } -if(part==3)color("limegreen")tag(); \ No newline at end of file diff --git a/make.sh b/make.sh index 71a6cf7..90c77e2 100755 --- a/make.sh +++ b/make.sh @@ -27,7 +27,7 @@ while [[ $# -gt 0 ]]; do shift echo -n generating for "$name" if [[ "$use_colorscad" == "true" ]]; then - "$colorscad" -i "AuerNameTag.scad" -o "$OUTDIR/${name}.3mf" -- -D "name=\"$name\"" -D "part=3" &>/dev/null & + "$colorscad" -i "AuerNameTag.scad" -o "$OUTDIR/${name}.3mf" -- -D "name=\"$name\"" -D "part=4" &>/dev/null & fi "$openscad" -o "$OUTDIR/${name}_text.stl" -D "name=\"$name\"" -D "part=2" "AuerNameTag.scad" &>/dev/null & "$openscad" -o "$OUTDIR/${name}_base.stl" -D "name=\"$name\"" -D "part=1" "AuerNameTag.scad" &>/dev/null &