Created
July 11, 2017 21:58
-
-
Save Neon22/e521042fcf30efa26c48c743bc541643 to your computer and use it in GitHub Desktop.
nametag in OpenSCAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fix indenting | |
Name = "First Name"; | |
Name2 = ""; | |
Length = 40; | |
Height = 2; | |
Width = 20; | |
Diameter = 15; | |
Diameter_Hole = 5; | |
Corner_Radius = 4; | |
Text_Height = 1; | |
Letter_Size = 4; | |
Emboss_Engrave = "Emboss"; // [Emboss, Engrave] | |
if (Emboss_Engrave == "Emboss") { | |
if (Name2 == "") { | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 0, 0]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
} else { | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 3, 0]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
linear_extrude(height = Height+Text_Height) | |
translate([8, -3, 0]) | |
text(Name2, size = Letter_Size, valign = "center", $fn = 100); | |
} | |
} | |
roundedcube(Length,Width,Height,Corner_Radius); | |
module roundedcube(Length,Width,Height,Corner_Radius) { | |
difference() { | |
hull(){ | |
translate([Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
} | |
// | |
if (Emboss_Engrave == "Engrave") { | |
if (Name2 == "") { | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 0, 5]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
} else { // Emboss | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 3, 0]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
linear_extrude(height = Height+Text_Height) | |
translate([8, -3, 0]) | |
text(Name2, size = Letter_Size, valign = "center", $fn = 100); | |
} | |
} | |
// | |
translate([3,0,0]) | |
cylinder(Diameter_Hole, Height, $fn=100); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// text in module | |
Name = "First Name"; | |
Name2 = ""; | |
Length = 40; | |
Height = 2; | |
Width = 20; | |
Diameter = 15; | |
Diameter_Hole = 5; | |
Corner_Radius = 4; | |
Text_Height = 1; | |
Letter_Size = 4; | |
Emboss_Engrave = "Emboss"; // [Emboss, Engrave] | |
module label () { | |
if (Name2 == "") { | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 0, 0]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
} else { | |
linear_extrude(height = Height+Text_Height) | |
translate([8, 3, 0]) | |
text(Name, size = Letter_Size, valign = "center", $fn = 100); | |
linear_extrude(height = Height+Text_Height) | |
translate([8, -3, 0]) | |
text(Name2, size = Letter_Size, valign = "center", $fn = 100); | |
} | |
} | |
if (Emboss_Engrave == "Emboss") { | |
label(); | |
} | |
roundedcube(Length,Width,Height,Corner_Radius); | |
module roundedcube(Length,Width,Height,Corner_Radius) { | |
difference() { | |
hull(){ | |
translate([Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
} | |
// | |
if (Emboss_Engrave == "Engrave") { | |
label(); | |
} | |
// | |
translate([3,0,0]) | |
cylinder(Diameter_Hole, Height, $fn=100); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fix text height, one or two line center | |
Name = "First Name"; | |
Name2 = ""; | |
Length = 40; | |
Height = 2; | |
Width = 20; | |
Diameter_Hole = 5; | |
Corner_Radius = 4; | |
Text_Height = 1; | |
Letter_Size = 4; | |
Emboss_Engrave = "Emboss"; // [Emboss, Engrave] | |
module label () { | |
if (Name2 == "") { | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([8, 0, 0]) | |
text(Name, size = Letter_Size, $fn = 100); | |
} else { | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([8, 3, 0]) | |
text(Name, size = Letter_Size, $fn = 100); | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([8, -3, 0]) | |
text(Name2, size = Letter_Size, $fn = 100); | |
} | |
} | |
if (Emboss_Engrave == "Emboss") { | |
label(); | |
} | |
roundedcube(Length,Width,Height,Corner_Radius); | |
module roundedcube(Length,Width,Height,Corner_Radius) { | |
difference() { | |
hull(){ | |
translate([Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
translate([Length-Corner_Radius,Height-Corner_Radius,0]) | |
cylinder(h=Height,r=Corner_Radius, $fn=100); | |
} | |
// | |
if (Emboss_Engrave == "Engrave") { | |
translate([0,0,Height-Text_Height]) | |
label(); | |
} | |
// | |
translate([3,0,0]) | |
cylinder(Diameter_Hole, Height, $fn=100); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fix hole, replace hull(), repo text, Use Width | |
Name = "First Name"; | |
Name2 = ""; | |
Length = 40; | |
Height = 2; | |
Width = 10; | |
Diameter_Hole = 3; | |
Corner_Radius = 4; | |
Text_Height = 1; | |
Letter_Size = 4; | |
Emboss_Engrave = "Emboss"; // [Emboss, Engrave] | |
/* [Hidden] */ | |
Line_offset = 0.75; // attempt at rough line separation value for given text height | |
Delta = 0.1; | |
cyl_res = 80; | |
module label () { | |
if (Name2 == "") { | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([(Width+Corner_Radius)/2, Letter_Size/4, 0]) | |
text(Name, size = Letter_Size, valign="center", $fn = 100); | |
} else { | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([(Width+Corner_Radius)/2, Letter_Size*Line_offset+Letter_Size/4, 0]) | |
text(Name, size = Letter_Size, valign="center", $fn = 100); | |
linear_extrude(height = Height+Text_Height, convexity=4) | |
translate([(Width+Corner_Radius)/2, -Letter_Size*Line_offset+Letter_Size/4, 0]) | |
text(Name2, size = Letter_Size, valign="center", $fn = 100); | |
} | |
} | |
module roundedcube(Length,Width,Height,Corner_Radius) { | |
difference() { | |
// rounded base | |
translate([0,-Corner_Radius,0]) | |
linear_extrude(height = Height, convexity=4) | |
offset(r=Corner_Radius/2, $fn=cyl_res) { | |
square(size=[Length, Width]); | |
} | |
// engraved only | |
if (Emboss_Engrave == "Engrave") { | |
translate([0,0,Height-Text_Height]) | |
label(); | |
} | |
// hole punch | |
translate([Diameter_Hole/2,Width/2-Corner_Radius,Delta]) | |
cylinder(h=Height+Delta*2, d=Diameter_Hole, $fn=100); | |
} | |
} | |
// | |
if (Emboss_Engrave == "Emboss") { | |
translate([0,0,-Delta]) | |
label(); | |
} | |
roundedcube(Length,Width,Height,Corner_Radius); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment