/* [Main design variables] */ variant = "stamp"; // ["stamp", "stencil"] // Set the width of the object. Height is calculated automatically. width = 80; // [0:200] // Set the text size to match the width. textsize = 12; // [10:36] font_set = 2; // [0:"linux", 1:"windows", 2:"custom", 3:"stencil"] font_index = 0; lines = ["line one", "line two"]; /* [common technical vars] */ linespacing_custom = 0.8; border = 0; /* [stamp technical vars] */ base_thickness_stamp = 1; base_rounding_stamp = 4; stamp_depth = 1.5; /* [stencil technical vars] */ base_thickness_stencil = 0.4; base_rounding_stencil = 2; /* [fonts] */ fonts_linux = [ ]; fonts_windows = [ ]; fonts_custom = [ "Anonymous Pro Minus:style=Bold", "Anonymous Pro Minus", "Kings:style=Regular", "CAT FrankenDeutsch:style=Regular", "Bounded:style=Medium" ]; fonts_stencil = ["Depot:style=Regular", "Depot Filled:style=Regular", "Allerta Stencil:style=Regular", "Stardos Stencil:style=Regular", "Stardos Stencil:style=Bold", "Stencilia\\-A:style=Regular", "Stencilia\\-Bold:style=Regular" ]; /* [hidden] */ linespacing = textsize*1.6 * linespacing_custom; height = (len(lines) * linespacing) + border*2; font_sets = [fonts_linux, fonts_windows, fonts_custom, fonts_stencil]; font = font_sets[font_set][font_index]; if (font == undef) { assert(false, "Font index out of range"); } if (version()[0] != 2021 || version()[1] != 1) { echo(); echo(); echo(); echo("WARNING!"); echo("Version is not 2021.01"); echo("Edit model text in the code editor"); echo("pending changes in the customizer may be overwritten"); echo(); echo(); echo(); } // All variables are set, make main main(); module main() { if (variant == "stamp") { scale([-1,1,1]) stamp(); translate([40,0,0]) %stamp(); } else if (variant == "stencil") { stencil(); } else { assert(false, "Invalid object variant"); } } module stamp_base(x, y, z, rounding) { hull() { for(i = [0+rounding,x-rounding]) { for(j = [0+rounding,y-rounding]) { translate([i,j,0]) cylinder(h = z, r = rounding); } } } } module stamp() { union() { stamp_base(x = width, y = height, z = base_thickness_stamp, rounding = base_rounding_stamp); for (i = [0 : 1 : len(lines)]) { line = lines[(len(lines)-1)-i]; translate(v = [width/2, linespacing/2 +border + i*linespacing, 0]) color("white") linear_extrude(height = base_thickness_stamp+stamp_depth) text(line, font = font, halign="center", valign="center", size=textsize); } } } module stencil() { difference() { stamp_base(width, height, base_thickness_stencil, base_rounding_stamp); for (i = [0 : 1 : len(lines)]) { line = lines[(len(lines)-1)-i]; translate(v = [width/2, linespacing/2 +border + i*linespacing, 0]) linear_extrude(height = base_thickness_stencil+0.01) text(line, font = font, halign="center", valign="center", size=textsize); } } }