- }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);
-*/