OpenSCAD More libraries

What is it?

Think of other files as libraries or utility files. A great utility file was created by member HarlanDMii It is called Write.scad. This utility allows you to add text to your 3D objects.

To use this file:
  1. Download the zip file


  2. These are the important files, so if you move things around, remember to keep these files together:



  3. Create a new openSCAD file and save it in the same directory as the files above.


  4. The first line of your file must be:
    use <Write.scad>
    
    



  5. Some helpful information about Write.scad

    The methods of Write.scad

    How to use the methods of Write.scad

    • write()
      This method takes several parameters:
      1. a string
      2. the letter thickness-optional
      3. the letter height-optional
      4. the rotation in degrees
      5. whether or not to center the text at the default origin-optional
      6. space=character widths-optional. This will resize the distance between letters. space=1 is default.. space=.8 will squeeze characters closer together.
      7. font="font.dxf"- (optional) This selects the font. The selected font will need to be in the working folder. You currently can select:
        • "letters.dxf" (default)
        • "braille.dxf"
        • "blackrose.dxf"
        • "orbitron.dxf"
        • "knewave.dxf"
      Because your string is surrounded by quotation marks if you want your string to include quotation marks you must use the backslash as an escape character
      \"
      
      or you can use a single quote and it will appear as a double quote.

      If you want to display the backslash character use the pipe:
      |
      
      write("openSCAD",t=5,h=10,center=true, font = "orbitron.dxf");



    • writecube()
      translate([10,20,30])
      cube(30,center=true); 
      writecube(text="text", where=[10,20,30], size=[30,30,30], font = "orbitron.dxf");
      
      or:
      translate([10,20,30])
      cube(30,center=true); 
      writecube("text",[10,20,30],30,  font = "orbitron.dxf");
      
      If the cube is not square, use the format [xsize,ysize,zsize]

      By default, writecube() will write on the front face of the box. This assumes that x=left to right, y=front to back, z=bottom to top. To write on the other sides, use:
      • face="top"
      • face="bottom"
      • face="back"
      • face="front"
      • face="left"
      • face="right"
      writecube("text",[10,20,30],30,  face="top",font = "orbitron.dxf");
      If you dont want the text centered, use
      • left=mm
      • up=mm
      • down=mm
      • right=mm
      These commands move the text along the plane in the given direction
      writecube("text",[10,20,30],30,  face="left",font = "orbitron.dxf", up=10);
      rotate You can rotate the text too:
      writecube("text",[10,20,30],30,  face="left",font = "orbitron.dxf", down=8,rotate=-30);
      If not specified, the text will be 4mm tall and 1mm thick. (half inside and half outside the cube)
      writecube("text",[10,20,30],30,  face="left",font = "orbitron.dxf", down=8,rotate=-30,t=2,h=4);
      Keep in mind,half the thickness of the text will be outside the cube and half inside the cube. This makes it easy to create indented or protruding text on your designs.



    • writesphere() The values for text=, where= and radius= are required, but if the values are entered in this order, then the commands are not required. These two examples produce the same results.
      sphere(10);
      color([0,1,1]) 
      writesphere(text="OpenSCAD", where=[0,0,0], radius=10, font = "orbitron.dxf");
      	
      sphere(10);
      color([0,1,1]) 
      writesphere("OpenSCAD", [0,0,0], 10, font = "orbitron.dxf");
      


      rounded= true or false (default = false)

      If the text is very large compaired to the sphere, the flat text might not conform to the sphere. Either make the text thicker, or make it rounded. Rounded text takes a lot longer to render, so be patient.
      sphere(10);
      color([0,1,1]) 
      writesphere("OpenSCAD", [0,0,0], 10, font = "orbitron.dxf", rounded=true);
      
      Spin rotates the text by degrees counter-clockwise:
      sphere(10);
      color([0,1,1]) 
      writesphere(text="OpenSCAD", where=[0,0,0], radius=10, font = "orbitron.dxf", rounded=true, spin=30);


      north=degrees or south=degrees will rotate the center of the text north or south.
      sphere(10);
      color([0,1,1]) 
      writesphere(text="OpenSCAD", where=[0,0,0], radius=10, font = "orbitron.dxf", rounded=true,  north=45);


      east=degrees or west=degrees will rotate the center of the text east or west
      sphere(10);
      color([0,1,1]) 
      writesphere(text="OpenSCAD", where=[0,0,0], radius=10, font = "orbitron.dxf", rounded=true,  east=45);




    • writecylinder()
      cylinder(r=10, h=10);
      translate([0,0,5])
      color([0,1,1]) 
      writesphere(text="OpenSCAD", where=[0,0,0], radius=10, font = "orbitron.dxf", east=15);




    • writecircle()
      circle(r=10);
      color([0,1,1]) 
      writecircle(text="OpenSCAD", where=[0,0,1], h=3,radius=6, font = "orbitron.dxf", space=1.3);