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:
To use this file:
- Download the zip file
-
These are the important files, so if you move things around, remember to keep these files together:
- Create a new openSCAD file and save it in the same directory as the files above.
- The first line of your file must be:
use <Write.scad>
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:- a string
- the letter thickness-optional
- the letter height-optional
- the rotation in degrees
- whether or not to center the text at the default origin-optional
- space=character widths-optional. This will resize the distance between letters. space=1 is default.. space=.8 will squeeze characters closer together.
- 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"
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()
or:
translate([10,20,30]) cube(30,center=true); writecube(text="text", where=[10,20,30], size=[30,30,30], font = "orbitron.dxf");
If the cube is not square, use the format [xsize,ysize,zsize]translate([10,20,30]) cube(30,center=true); writecube("text",[10,20,30],30, font = "orbitron.dxf");
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"
If you dont want the text centered, usewritecube("text",[10,20,30],30, face="top",font = "orbitron.dxf");
- left=mm
- up=mm
- down=mm
- right=mm
rotate You can rotate the text too:writecube("text",[10,20,30],30, face="left",font = "orbitron.dxf", up=10);
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);
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.writecube("text",[10,20,30],30, face="left",font = "orbitron.dxf", down=8,rotate=-30,t=2,h=4);
- 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.Spin rotates the text by degrees counter-clockwise:sphere(10); color([0,1,1]) writesphere("OpenSCAD", [0,0,0], 10, font = "orbitron.dxf", rounded=true);
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 westsphere(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);
- write()