Skip to content

Instantly share code, notes, and snippets.

@Kadajett
Created July 17, 2017 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kadajett/0caea74781906ace92bea55f54ff31fc to your computer and use it in GitHub Desktop.
Save Kadajett/0caea74781906ace92bea55f54ff31fc to your computer and use it in GitHub Desktop.
module textCylinder( text="TEST"
,r=30
,h=2 // embosed height of letters
,size=10 // text(size=)
,rotate=[0,0,0] // | y= rotate face of text
// | z= rotate around the circumference
// | x is ignored
,font=undef // : these allow default value in text()
,spacing=undef // : undef gets rid of WARNING unknown variable
,language=undef
,script=undef
,valign=undef
,halign="center" // is centered due to the technique used here
// feel free to try others, YMMV.
,direction=undef
) {
s=0.1; s2=s*2; // small, for difference etc.
l=3; // large (as a multiplyer) to allow for text size irregularity
tall=( rotate!=[0,0,0] || direction=="btt" || direction=="ttb" );
_h= ( tall // keep cut cylinders to reasonable size
? (size*len(text)*l)
: size*l );
_r=(r+h)*l;
//echo(r=r,h=h,text=text,size=size,rotate=rotate);
//echo(l=l,tall=tall,_h=_h,_r=_r);
difference() {
rotate([90,rotate[1],rotate[2]])
linear_extrude(height=r+h,convexity=5)
text(text,size,halign="center"
,font=font
,spacing=spacing
,language=language
,script=script
,valign=valign
,direction=direction
);
// -
translate([0,0,size/2]) {
cylinder(r=r,h=_h,center=true);
difference() {
cylinder(r=_r,h=_h+s,center=true);
// -
cylinder(r=r+h,h=_h+s2,center=true);
} //d
} // t
} // d
} // textCylinder
// _____________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment