master
Gnieark 9 years ago
parent 4c3993b47a
commit 7b80b9aa1b

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,9 @@
use<write.scad>
writesphere("Be kind to others",[0,0,12],40.5,font="braille.dxf",space=1.2);
writesphere("Be kind to others",[0,0,6],40.5,space=1.2);
writesphere("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ;:.,!?"
,[0,0,0],40.5,font="orbitron.dxf",space=1.1);
writesphere("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ;:.,!?"
,[0,0,-6],40.5,font="braille.dxf",space=1.1);

@ -0,0 +1,52 @@
/*
********************************************************
By Harlan Martin
harlan@sutlog.com
January 2012
1... The quote " symbol cannot be inserted into a string alone
Either use \" or just the single quote' will show as "
2... The \ is used for special text characters, so use the bar | to
show the back slash \
------------------------------------------------------------------------------------
Usage...
write("my text",t=3,h=5,center=true);
(t) (optional) The thickness of the letters in mm.
The default is 1mm if not specified
(h)(optional) The height of the letters in mm.
The default is 8mm if not specified
(center) (optional) Centers the text at default coordinates.
Put the files (write.scad) and (letters.dfx) in the
working directory with your project
------------------------------------------------------------------------------------------
********************************************************
*/
include <write.scad>
// remember when centered, the text is centered on the [x,y,z] vector
// if you place centered text on the surface,half is inside, half is out
difference(){
translate([0,0,0])
cube(20,center=true);
translate([0,-10,0])
rotate(90,[1,0,0])
write("Indented Text",h=2,t=1,center=true);
translate([0,0,-6])
rotate(90,[1,0,0])
write("Cut",h=8,t=30,center=true);
}
translate([0,-10,7])
rotate(90,[1,0,0])
write("Raised Text",h=2,t=1,center=true);

@ -0,0 +1,82 @@
use <write.scad>
/*
********************************************************
By Harlan Martin
harlan@sutlog.com
January 2012
1... The quote " symbol cannot be inserted into a string alone
Either use \" or just the single quote' will show as "
2... The \ is used for special text characters, so use the bar | to
show the back slash \
------------------------------------------------------------------------------------
Usage...
write("my text",t=3,h=5,center=true);
(t) (optional) The thickness of the letters in mm.
The default is 1mm if not specified
(h)(optional) The height of the letters in mm.
The default is 8mm if not specified
(center) (optional) Centers the text at default coordinates.
Put the files (write.scad) and (letters.dfx) in the
working directory with your project
------------------------------------------------------------------------------------------
//------------------------Examples ----------------------------------------------------
use <write.scad> // Dont forget to include this line and the files
//example1: Uses all declarations..
translate([20,15,0])
write("Example 1",t=4,h=5.75,center=true);
//example2: Quick and easy
write("That was easy!",h=12);
//example3: move and rotate(front) (remember to translate..then rotate)
translate([0,0,10])
rotate(90,[1,0,0]) // rotate around the x axis
write("Rotate +X 90 (front)",t=2);
//example4: move and rotate(left side)
translate([0,0,20])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,-1,0]) // rotate around the y axis
write("Rotate +X 90 and -Y 90 (left side)");
//example5: move and rotate(right side)
translate([0,0,30])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,1,0]) // rotate around the y axis
write("Rotate +X 90 and +Y 90 (right side)");
//example6: move and rotate(back)
translate([0,0,40])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(180,[0,1,0]) // rotate around the y axis
write("Rotate +X 90 and +Y 180 (back)");
********************************************************
*/
translate([0,30,0])
write("abcdefghijklmn",t=10.5,h=10,center=true);translate([0,0,0])
translate([0,15,0])
write("opqrstuvwxyz",t=9,h=9,center=true);
translate([0,0,0])
write("~!@#$%^&*()_-+=",t=7.5,h=8,center=true);
translate([0,-15,0])
write(",./<>?;'`:[]{}|",t=6,h=7,center=true);
translate([0,-30,0])
write("ABCDEFGHIJKLMN",t=4.5,h=6,center=true);translate([0,0,0])
translate([0,-45,0])
write("OPQRSTUVWXYZ",t=3,h=5,center=true);
translate([0,-60,0])
write("\"",t=1.5,h=4,center=true);

@ -0,0 +1,103 @@
/*
for these examples, assume we have the cube:
translate([10,20,30])
cube(30,center=true);
-----------------------text where and size--------------------------------
The values for text=, where= and size= are required, but if the
values are entered in this order, then the commands are not
required. These three examples produce the same results.
writecube(text="text", where=[10,20,30], size=[30,30,30]);
writecube("text",[10,20,30], [30,30,30]);
writecube("text",[10,20,30],30);
text="whatever text you want to write"
where= the center coordinates of the box
size = size of box. Either [xsize,ysize,zsize] or just size if its square
----------------------------face = ----------------------------------------
By default, writecube will write on the front of the box assuming
x=left to right, y=front to back, z=bottom to top
to write on another side, use face="top","bottom","back","front",
"left" or "right"
writecube("Howdy!!",[10,20,30],30,face="left");
will print Howdy!! on the center left of the box.
-------------------- left, right, up, down---------------------------------
If you dont want it centered, use left=mm or up=mm or down...
These commands move the text along the plane in the givin
direction (in relation to the unrotated text) in specified milimeters.
writecube("HI!!",[10,20,30],30,face="top",up=5);
will write HI!! 5mm away from you along the top plane of the box
------------------------------- rotate -----------------------------------
You say you dont want the text aligned with the sides?
rotate = angle will fix that for you. It rotates the text clockwise
along the plane of the text.
writecube("Aloha!!",[10,20,30],30,face="front",down=8,rotate=-30);
------------------------- text size and thickness -----------------------
t=how thick the text will be
h=height of the font or fontsize
if not specified, the text will be 4mm tall (upper case)
and 1mm thick. (half inside and half outside the cube)
writecube("Hello!!",[10,20,30],30,face="right", t=2,h=4);
will write Hello!! on the right side of the cube with 1mm sticking out
Keep in mind, if a font is 2mm thick, 1mm will be inside the cube
or if its 4mm, 2mm will be inside.
*/
// press f5 to see transparent cube.. remove % from cube otherwise
use<write.scad>
translate([10,20,30])
% cube(30,center=true);
writecube("text",[10,20,30],30);
writecube("Howdy!!",[10,20,30],30,face="left");
writecube("Aloha!!",[10,20,30],30,face="front",down=8,rotate=-30);
writecube("HI!!",[10,20,30],30,face="top",up=5);
writecube("Hello!!",[10,20,30],30,face="right", t=2,h=6);
writecube("Hola!!",[10,20,30],[30,30,30],face="back");
writecube("Salut!!",[10,20,30],[30,30,30],face="bottom");

@ -0,0 +1,83 @@
/* NOTES:
writecylinder(text="text",where=[0,0,0],radius=20,height=40);
Required Parameters (If supplied in this order, identifier is not required)
text="text" : Text to be written
where=[x,y,z] : coordinates of cylinder
radius=mm : radius of cylinder
height=mm : height of cylinder
Optional Parameter:
center=boolean : use this to specify that cylinder is centered on coordinates
(default is center=false)
face="top" : Top of cylinder
face="bottom": bottom of cylinder
face="front" :barrel of cylinder (default if not supplied)
Optional Parameters: (face is not "top" or "bottom")
east=degrees : west= degrees: (moves text east or west around z)
up=mm or down=mm : moves text up or down along Z axis
rotate=degrees : rotates text around Y axis (spirals around cylinder)
Optional Parameters: (face="top" or face="bottom")
east=degrees or west=degrees : rotate text east or west around top
rotate=degrees : (similar to east west but not dependant on text orientation)
ccw=boolean : If true, writes in a counter clockwise direction. (default=false)
middle=mm :moves the text ?mm toward center of top or bottom surface
*/
use <write.scad>
translate([0,0,0])
%cylinder(r=20,h=40);
writecylinder("rotate=90",[0,0,0],20,40,rotate=90);
writecylinder("rotate = 30,east = 90",[0,0,0],20,40,space=1.2,rotate=30,east=90);
writecylinder("ccw = true",[0,0,0],20,40,face="top",ccw=true);
writecylinder("middle = 8",[0,0,0],20,40,h=3,face="top",middle=8);
writecylinder("face = top",[0,0,0],20,40,face="top");
writecylinder("east=90",[0,0,0],20,40,h=3,face="top",east=90);
writecylinder("west=90",[0,0,0],20,40,h=3,face="top",ccw=true,west=90);
writecylinder("face = bottom",[0,0,0],20,40,face="bottom");

@ -0,0 +1,14 @@
use<write.scad>;
// writesphere(text="text",where=[0,0,0],radius=radius of sphere);
//assuming z+ = north
//rotate(angle,[1,0,0]) // will move text north or south
//rotate(angle,[0,1,0]) // will rotate text like a clock hand
//rotate(angle,[0,0,1]) // will move text east or west
//detailed useage is in the WriteScadDoc
//rounded=true makes the face of the letters rounded, but takes longer to render
%sphere(10);
writesphere("Hello World",[0,0,0],10,spin=-45,north=30,east=10);

@ -0,0 +1,378 @@
/* Version 3
Added support for font selection (default is Letters.dxf)
Added WriteCube module
Added Rotate for text (rotates on the plane of the text)
Added writesphere
Added space= (spacing between characters in char widths) def=1
Added writecylinder()
By Harlan Martin
harlan@sutlog.com
January 2012
(The file TestWrite.scad gives More usage examples)
(This module requires the file Letters.dxf to reside in the same folder)
(The file Letters.dfx was created with inkscape..Each letter is in its own layer)
(This module seperates each letter in the string and imports it from Letters.dfx)
*/
pi=3.1415926535897932384626433832795028841971693993751058209;
pi2=pi*2;
// These control the default values for write() writesphere() writecube()
// if the parameters are not included in the call. Feel free to set your own
// defaults.
//default settings
center=false;
h = 4; //mm letter height
t = 1; //mm letter thickness
space =1; //extra space between characters in (character widths)
rotate=0; // text rotation (clockwise)
font = "Letters.dxf"; //default for aditional fonts
// write cube defaults
face = "front"; // default face (top,bottom,left,right,back,front)
up =0; //mm up from center on face of cube
down=0;
right =0; //mm left from center on face of cube
left=0;
// write sphere defaults
rounded=false; //default for rounded letters on writesphere
north=0; // intial text position (I suggest leave these 0 defaults)
south=0;
east=0;
west=0;
spin=0;
// writecylinder defaults
middle=0; //(mm toward middle of circle)
ccw=false; //write on top or bottom in a ccw direction
r1=0; //(not implimented yet)
r2=0; //(not implimented yet)
// Contact me if your interested in how to make your own font files
// Its tedious and time consuming, but not very hard
module writecylinder(text,where,radius,height){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if ((face=="top")||(face=="bottom") ){
if (face=="top" ){
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,height],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}else{
rotate(180,[1,0,0])
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,0],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}
}else{
// if (radius>0){
if (center==true) {
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where)
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
} else{
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where+[0,0,height/2])
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
}
// the remarked out code is for cone shaped cylinders (not complete)
// }else{
// if (center==true) {
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where)
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// } else{
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where+[0,0,height/2])
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// }
// }
}
}
module writecircle(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if (ccw==true){
rotate(-rotate+east-west,[0,0,1]){
rotate(-mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(-270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}else{
rotate(-rotate-east+west,[0,0,1]){
rotate(mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(90-r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}
}
module writethecylinder(text,where,radius,height,r1,r2){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360*(1-abs(rotate)/90);
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
translate([0,0,up-down])
rotate(east-west,[0,0,1])
for (r=[0:len(text)-1]){
rotate(-90+(r*NAngle(radius)),[0,0,1])
translate([radius,0,-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid)])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
//echo("zloc=",height/2-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid));
}
}
module writesphere(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
echo("-----------------",widall,wid,mmangle(radius));
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
rotate(east-west,[0,0,1]){
rotate(south-north,[1,0,0]){
rotate(spin,[0,1,0]){
rotate(-mmangle(radius),[0,0,1]){
if ( rounded== false ){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
}
}else{
difference(){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t*2+h,font=font);
}
difference(){ //rounded outside
sphere(radius+(t*2+h)*2);
sphere(radius+t/2);
}
sphere(radius-t/2); // rounded inside for indented text
}
}
}
}}}
}
module writecube(text,where,size){
if (str(size)[0] != "["){
// its a square cube (size was not a matrix so make it one)
writethecube(text,where,[size,size,size],h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}else{
// its not square
writethecube(text,where,size,h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}
}
// I split the writecube module into 2 pieces.. easier to add features later
module writethecube(text,where,size){
if (face=="front") {
translate([where[0]+right-left,where[1]-size[1]/2,where[2]+up-down])
rotate(90,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
if (face=="back") {
translate([where[0]+right-left,where[1]+size[1]/2,where[2]+up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(180,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
if (face=="left") {
translate([where[0]-size[0]/2,where[1]-right+left,where[2]+up-down ])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,-1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
if (face=="right") {
translate([where[0]+size[0]/2,where[1]+right-left,where[2] +up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
if (face=="top") {
translate([where[0]+right-left,where[1]+up-down,where[2]+size[2]/2 ])
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
if (face=="bottom") {
translate([where[0]+right-left,where[1]-up+down,where[2]-size[2]/2 ])
rotate(180,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font,space=space);
}
}
module write(word){
echo (h);
echo (word);
echo ("There are " ,len(word) ," letters in this string");
// echo ("The second letter is ",word[1]);
// echo (str(word[0],"_"));
rotate(rotate,[0,0,-1]){
for (r = [0:len(word)]){ // count off each character
// if the letter is lower case, add an underscore to the end for file lookup
if ((word[r] == "a" ) || (word[r]== "b") || (word[r]== "c")
|| (word[r]== "d") || (word[r]== "e") || (word[r]== "f")
|| (word[r]== "g") || (word[r]== "h") || (word[r]== "i")
|| (word[r]== "j") || (word[r]== "k") || (word[r]== "l")
|| (word[r]== "m") || (word[r]== "n") || (word[r]== "o")
|| (word[r]== "p") || (word[r]== "q") || (word[r]== "r")
|| (word[r]== "s") || (word[r]== "t") || (word[r]== "u")
|| (word[r]== "v") || (word[r]== "w") || (word[r]== "x")
|| (word[r]== "y" )|| (word[r]== "z")){
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}
}else{
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}
}
}
}
}
/*writecylinder test
translate([0,0,0])
%cylinder(r=20,h=40,center=true);
color([1,0,0])
writecylinder("rotate=90",[0,0,0],20,40,center=true,down=0,rotate=90);
writecylinder("rotate = 30,east = 90",[0,0,0],20,40,center=true,down=0,rotate=30,east=90);
writecylinder("ccw = true",[0,0,0],20,40,center=true,down=0,face="top",ccw=true);
writecylinder("middle = 8",[0,0,0],20,40,h=3,center=true,down=0,face="top",middle=8);
writecylinder("face = top",[0,0,0],20,40,center=true,down=0,face="top");
writecylinder("east=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",east=90);
writecylinder("west=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",ccw=true,west=90);
writecylinder("face = bottom",[0,0,0],20,40,center=true,down=0,face="bottom");
*/
/*writesphere test
sphere(20);
color([1,0,0])
writesphere("Hello World",[0,0,0],20,t=1,h=6);
*/
/* writecube test
translate([30,30,30])
cube([10,15,30],center=true);
write("hello",center=true,rotate =30);
color([1,0,0])
writecube( "front",[30,30,30],[10,15,30],h=5,rotate=-90);
color([0,1,0])
writecube( "back",[30,30,30],size=[10,15,30],h=5,face="back",rotate=90,t=4);
color([0,0,1])
writecube( "left",[30,30,30],[10,15,30],h=5,face="left",up=5);
color([1,1,0])
writecube( "right",where=[30,30,30],size=[10,15,30],h=5,face="right",rotate=55);
color([1,0,1])
writecube( "top",where=[30,30,30],size=[10,15,30],h=5,face="top");
color([1,1,1])
writecube( "bttm",where=[30,30,30],size=[10,15,30],h=5,face="bottom",rotate=90);
*/

@ -0,0 +1,378 @@
/* Version 3
Added support for font selection (default is Letters.dxf)
Added WriteCube module
Added Rotate for text (rotates on the plane of the text)
Added writesphere
Added space= (spacing between characters in char widths) def=1
Added writecylinder()
By Harlan Martin
harlan@sutlog.com
January 2012
(The file TestWrite.scad gives More usage examples)
(This module requires the file Letters.dxf to reside in the same folder)
(The file Letters.dfx was created with inkscape..Each letter is in its own layer)
(This module seperates each letter in the string and imports it from Letters.dfx)
*/
pi=3.1415926535897932384626433832795028841971693993751058209;
pi2=pi*2;
// These control the default values for write() writesphere() writecube()
// if the parameters are not included in the call. Feel free to set your own
// defaults.
//default settings
center=false;
h = 4; //mm letter height
t = 1; //mm letter thickness
space =1; //extra space between characters in (character widths)
rotate=0; // text rotation (clockwise)
font = "Letters.dxf"; //default for aditional fonts
// write cube defaults
face = "front"; // default face (top,bottom,left,right,back,front)
up =0; //mm up from center on face of cube
down=0;
right =0; //mm left from center on face of cube
left=0;
// write sphere defaults
rounded=false; //default for rounded letters on writesphere
north=0; // intial text position (I suggest leave these 0 defaults)
south=0;
east=0;
west=0;
spin=0;
// writecylinder defaults
middle=0; //(mm toward middle of circle)
ccw=false; //write on top or bottom in a ccw direction
r1=0; //(not implimented yet)
r2=0; //(not implimented yet)
// Contact me if your interested in how to make your own font files
// Its tedious and time consuming, but not very hard
module writecylinder(text,where,radius,height){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if ((face=="top")||(face=="bottom") ){
if (face=="top" ){
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,height],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}else{
rotate(180,[1,0,0])
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,0],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}
}else{
// if (radius>0){
if (center==true) {
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where)
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
} else{
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where+[0,0,height/2])
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
}
// the remarked out code is for cone shaped cylinders (not complete)
// }else{
// if (center==true) {
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where)
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// } else{
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where+[0,0,height/2])
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// }
// }
}
}
module writecircle(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if (ccw==true){
rotate(-rotate+east-west,[0,0,1]){
rotate(-mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(-270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}else{
rotate(-rotate-east+west,[0,0,1]){
rotate(mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(90-r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}
}
module writethecylinder(text,where,radius,height,r1,r2){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360*(1-abs(rotate)/90);
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
translate([0,0,up-down])
rotate(east-west,[0,0,1])
for (r=[0:len(text)-1]){
rotate(-90+(r*NAngle(radius)),[0,0,1])
translate([radius,0,-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid)])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
//echo("zloc=",height/2-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid));
}
}
module writesphere(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
echo("-----------------",widall,wid,mmangle(radius));
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
rotate(east-west,[0,0,1]){
rotate(south-north,[1,0,0]){
rotate(spin,[0,1,0]){
rotate(-mmangle(radius),[0,0,1]){
if ( rounded== false ){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
}
}else{
difference(){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t*2+h,font=font);
}
difference(){ //rounded outside
sphere(radius+(t*2+h)*2);
sphere(radius+t/2);
}
sphere(radius-t/2); // rounded inside for indented text
}
}
}
}}}
}
module writecube(text,where,size){
if (str(size)[0] != "["){
// its a square cube (size was not a matrix so make it one)
writethecube(text,where,[size,size,size],h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}else{
// its not square
writethecube(text,where,size,h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}
}
// I split the writecube module into 2 pieces.. easier to add features later
module writethecube(text,where,size){
if (face=="front") {
translate([where[0]+right-left,where[1]-size[1]/2,where[2]+up-down])
rotate(90,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="back") {
translate([where[0]+right-left,where[1]+size[1]/2,where[2]+up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(180,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="left") {
translate([where[0]-size[0]/2,where[1]-right+left,where[2]+up-down ])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,-1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="right") {
translate([where[0]+size[0]/2,where[1]+right-left,where[2] +up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="top") {
translate([where[0]+right-left,where[1]+up-down,where[2]+size[2]/2 ])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="bottom") {
translate([where[0]+right-left,where[1]-up+down,where[2]-size[2]/2 ])
rotate(180,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
}
module write(word){
echo (h);
echo (word);
echo ("There are " ,len(word) ," letters in this string");
// echo ("The second letter is ",word[1]);
// echo (str(word[0],"_"));
rotate(rotate,[0,0,-1]){
for (r = [0:len(word)]){ // count off each character
// if the letter is lower case, add an underscore to the end for file lookup
if ((word[r] == "a" ) || (word[r]== "b") || (word[r]== "c")
|| (word[r]== "d") || (word[r]== "e") || (word[r]== "f")
|| (word[r]== "g") || (word[r]== "h") || (word[r]== "i")
|| (word[r]== "j") || (word[r]== "k") || (word[r]== "l")
|| (word[r]== "m") || (word[r]== "n") || (word[r]== "o")
|| (word[r]== "p") || (word[r]== "q") || (word[r]== "r")
|| (word[r]== "s") || (word[r]== "t") || (word[r]== "u")
|| (word[r]== "v") || (word[r]== "w") || (word[r]== "x")
|| (word[r]== "y" )|| (word[r]== "z")){
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}
}else{
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}
}
}
}
}
/*writecylinder test
translate([0,0,0])
%cylinder(r=20,h=40,center=true);
color([1,0,0])
writecylinder("rotate=90",[0,0,0],20,40,center=true,down=0,rotate=90);
writecylinder("rotate = 30,east = 90",[0,0,0],20,40,center=true,down=0,rotate=30,east=90);
writecylinder("ccw = true",[0,0,0],20,40,center=true,down=0,face="top",ccw=true);
writecylinder("middle = 8",[0,0,0],20,40,h=3,center=true,down=0,face="top",middle=8);
writecylinder("face = top",[0,0,0],20,40,center=true,down=0,face="top");
writecylinder("east=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",east=90);
writecylinder("west=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",ccw=true,west=90);
writecylinder("face = bottom",[0,0,0],20,40,center=true,down=0,face="bottom");
*/
/*writesphere test
sphere(20);
color([1,0,0])
writesphere("Hello World",[0,0,0],20,t=1,h=6);
*/
/* writecube test
translate([30,30,30])
cube([10,15,30],center=true);
write("hello",center=true,rotate =30);
color([1,0,0])
writecube( "front",[30,30,30],[10,15,30],h=5,rotate=-90);
color([0,1,0])
writecube( "back",[30,30,30],size=[10,15,30],h=5,face="back",rotate=90,t=4);
color([0,0,1])
writecube( "left",[30,30,30],[10,15,30],h=5,face="left",up=5);
color([1,1,0])
writecube( "right",where=[30,30,30],size=[10,15,30],h=5,face="right",rotate=55);
color([1,0,1])
writecube( "top",where=[30,30,30],size=[10,15,30],h=5,face="top");
color([1,1,1])
writecube( "bttm",where=[30,30,30],size=[10,15,30],h=5,face="bottom",rotate=90);
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,3 +1,5 @@
use <Writescad/Write.scad>
linear_extrude (height=3)
import (file="piece_coin.dxf", layer="piececoin2", $fn=100);
difference(){
@ -9,7 +11,17 @@ difference(){
translate([40, -32, 20.5]) rotate ([0, 90, 30]) cylinder(r=1.5, h=60, $fn=50);
translate([-60, -2, 20.5]) rotate ([0, 90, -30]) cylinder(r=1.5, h=60, $fn=50);
translate([15.1, -2, 20.5]) rotate ([270, 0,0 ]) cylinder(r=1.5, h=60, $fn=50);
translate([15.1, -2, 20.5]) rotate ([270, 0,0 ]) cylinder(r=1.5, h=60, $fn=50);
translate([15.1, 45, 20.5]) rotate ([270, 0,0 ]) cylinder(r=5, h=12, $fn=50);
translate([15.1, -26, 20.5]) rotate ([270, 0,0 ]) #cylinder(r=5, h=12, $fn=50);
translate([-38,19.6,10])
rotate ([90,0,240])
write("Reprap Jeanne V2",h=3.5,t=2);
translate([86,-12,10])
rotate ([90,0,120])
write("Reprap Jeanne V2",h=3.5,t=2);
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save