Loading

Write.scad

by HarlanDMii, published

Write.scad by HarlanDMii Jan 18, 2012

Description

UPDATED: 04/30/2014 Added bold=
(be sure to download the latest version of write.scad to use this feature)
bold=0 (not bold) bold=1(bolder by 10%) bold=2 (bolder by 20%) etc.. (fractions work too) Thanks MichaelAtOz for minkowski tip :)
examples
write("Hello world",bold=1)
or
writesphere("Hello World",[15,15,15],12,bold=.5);

UPDATED: 04/24/2013 M_G pointed out that space didn't work properly on writecube.. (fixed) Thanks M_G!!
UPDATED: 03/06/2013 Added Help file for creating fonts.
I have looked everywhere for an easy way to write on my 3d objects. Everything I could find was hard to manipulate, so I decided to give it a shot myself. Hope you like this as much as I do. I'll try to answer any questions you have.

write.scad Routines:
write()
writecube()
writesphere()
writecylinder()
writecircle()

Fonts:
letters.dxf (change in write.scad)
orbitron.dxf
braille.dxf
knewave.dxf
BlackRose.dxf
-------------------------
writecylinder specs in testwritecylinder.scad
-------------------------
Be glad to add more fonts if requested, or give details to make your own.

Recent Comments

view all
Hello,
I'm newer on the community. I use the OpenScad version 2014.03.
I downloaded your module. Thanks for that it's fun.
Now I have some troubles when I had wanted test the module in using your example described on the "Instructions" section. Often the text does not follow the forms (for a same shifting); it is not correctly moved.
I fixed the issues in my side. By personal message, I can send you my version, you are certainly interested to have a look.
HTH,
Regards
Cyril
Added bold option. I will try to improve the speed first chance I get, but seems to work pretty well as is

Makes

Liked By

view all

License

Write.scad by HarlanDMii is licensed under the Creative Commons - Attribution license.

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

openscad version 2011.12 or later is required to be able to run this code. Be sure to download the latest version from openscad.org/

Put the files (write.scad) and (letters.dfx) in
the working directory with your open scad project.
refrence write.scad in your code...(use)

NOTE: write.scad contains write(),writesphere(),writecube() and writecylinder() modules

// write anywhere in your openscad project
locate([x,y,z])
write("Hello World",h=6,t=3);

// change fonts and spacing
write("Hello World",h=6,t=3,font="knewave.dxf",space=1.1);

// write on a cube
translate([15,15,15])
cube([20,20,10]);
writecube("Hello World",[15,15,15],[20,20,10],face="top");

// write on a sphere
translate([15,15,15])
sphere(12);
writesphere("Hello World",[15,15,15],12);

// write on a cylinder
translate([0,0,0])
cylinder(r=20,h=40,center=true);
writecylinder("Text on Cylinder",[0,0,0],20,40,rotate=45,center=true);
writecylinder("Text on top",[0,0,0],20,40,face="top",center=true);
//detailed usage in testwritecylinder.scad
//be sure to download the latest write.scad to use the new commands

// write in circles
writecircle("text",[0,0,0],radius);
=================================================================
=================================================================
You are welcome to use and distribute this code freely. no need to make it a derivative of write.scad

Check back every once in a while for additions.

If you make something really cool that uses it, let me know. I want to see :)

HAVE FUN WITH IT, and comments are always appreciated.

File Name

Downloads

Size

Hello,
I'm newer on the community. I use the OpenScad version 2014.03.
I downloaded your module. Thanks for that it's fun.
Now I have some troubles when I had wanted test the module in using your example described on the "Instructions" section. Often the text does not follow the forms (for a same shifting); it is not correctly moved.
I fixed the issues in my side. By personal message, I can send you my version, you are certainly interested to have a look.
HTH,
Regards
Cyril
Make a Bold option please!
Added bold option. I will try to improve the speed first chance I get, but seems to work pretty well as is
Bold options need to be added! Many printers are not capable of printing with fonts so thinly featured. Perhaps add another parameter to the module called "style." Examples: style=bold or style=italic
I was looking through some new commands on OpenScad to see if there were any promising new features that would make it smooth and easy. It looks like offset() is exactly what I need to make it happen... Unfortunately, That command is only available on the beta release of openscad. It looks like that version might also be released with its own text functions built in too!! We'll have to see what Marius Kintel does with it :)
Do you have any idea when that be released?
While you're waiting:use <writewrite.scad>
minkowski() {
write("hello");
cylinder(r=0.25);
}
translate([0,-10,0])
write("world");
minkowski did a surprisingly well !!. I used cube instead of cylinder to keep the number of faces to a reasonable level, but still be careful with very long strings.. Things can get real slow real quick.just add bold=1 (or some number between .1 and 10) to make text bolderexamples
write("Hello world",bold=1)
or
writesphere("Hello World",[15,15,15],12,bold=.5);
Oh yea, bold=0 is the default value
Not required if your not making text bold
I sent a github pull request for a (mostly harmless) off-by-one error in the write() module. I'd also be interested in any feedback about making my work-in-progress font at github.com/beanz/celtic-knot-scad/blob/font/celtic-knot-font-example.scad easier for users to work with.
Oh, the GitHub version is not the canonical one, I just mirror the Thingiverse releases there so I can easily integrate them into my things.Nevertheless, HarlanDMii, you most probably understand the code best, could you have a look if github.com/rohieb/Write.scad/pull/1/files makes sense to you?
The correction on the github sight is correct. Can't believe I hadn't noticed it. Thanks hindessm :)
The count loop starts at 0, so it should only count from 0 to Numberofletters -1
Hi! Thank you for putting this up here!
I have a quick question, is there any way to get the text to wrap around a cone-shaped object? Would I have to give the text a slant so that it stays parallel to the surface of the cone?
Also, how do you indent the text?
Thank you so much!
Nice! One question: can you upload those .svg files to be able to add some missing characters to those fonts?
Like ç é à etc. Greatly done! Thx!
Not sure how I failed to include them in the later zip file, but the svg files for the fonts are included in the WriteScad_01_29_2012.zip file
Thx a mill ;-)
Downloaded the knewave.ttf font and installed it. Opened inkscape created new layer, named it ç and put text ç with knewave font on it.
Created path of ç and saved it as dxf and svg.
So far ok. but now when I try to use it in openscad by write.scad I'm not succesfull.
Is this due to the UTF-8 format of the ç?
Greetz Xiao Shi Zi.
I have been trying to figure out why ç won't work. It looks like there is a problem in the way that python handles ascii codes. It will only work with ascii characters from 1 to 128.. I'll keep looking for a way around it.
Concerning python I've added the following in another programm to be able to use chinese text like my name ???.
My first two lines loke like:

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-

Maybe I'm wrong but is Openscad writen in Python? IMHO this is an openscad problem.
Could be interesting to check
github.com/openscad/openscad/issues/512
they have like a text module in Openscad including ttf or otf fonts. I wasn't succesfull to make it run on Ubuntu yet.
Hopefully you'll be succesfull soon ;-)
Greetings,

Xiao Shi Zi.
finally I posted a "working" version.

thingiverse.com/thing:251040
Thx HarlanDMii!
Really nice script! I used it to design customizable rings for my Flash Drive Cryptex: thingiverse.com/thing:184911
I wouldn't have been able to realize it without your work. Thanks!
Eureka!! Your basics tutorial did it. It didn't work immediately as I managed to load two files twice somehow and my computer renamed letters, "letters2"! anyway I did figure that basic mistake out and renamed the file back to just "letters", it started working. I'm off and running. Thank you soooo much...
The other problem I have is following directions. I downloaded the wrong pdf. Just reread your comment to download the "getting started pdf. That looks like what I want. I'll get started after dinner. Thanks!!
Spent an hour on this and not getting anywhere. The problem is apparently I'm not understanding directories? I have the 2013 openscad, the write scad and letters.dxf file downloaded but they must be in different places and maybe that's why they are not working. If I click on the write program it opens in the openscad editor OK but nothing happens when I hit F5. If I open the dxf file openscad opens up and this appears in the editor: "import("C:/Users/Dave/Downloads/Letters(1).dxf"); " but if I hit f5 openscad closes claiming there is a problem?? Are these files supposed to open in the openscad editor?
Thank you for the reply. I have used openscad a lot for the last 2 months since I got my printer. Mostly I mimic and then change things to get what I want or to see what happens. After a couple of weeks I was writing my own openscad programs including my own tedious "rounding routine". It's the way some of us rednecks learn. Unfortunately it's not as efficient as actually "knowing" what your doing as a learning tool. My extent of using openscad is: downloaded it, learned to make boxes,sphere's,cylinders and modules, translate (that took a while), difference etc. - familiar with F5,F6 and saving .stl files. - wander around in the dark making things that turn out good in print but the code is long and tedious and is best kept hidden away from real programmers eyes! BUT I have no idea how to (for lack of a better word) "meld" other programs or files to openscad like write scad or some of the thread programs etc. If it was a piece of code I could place in my program I could figure out where to put it and place it in 3d.? I have been busy so I will try to re look at the directions later tonight and get back if it makes sense. I did search through the beginning online tutorials about openscad and must have missed the steps. A thing called "library's" was mentioned and I'm guessing that is what this is all about but I don't know how to get them connected to my program designs. If they were connected I probably have the juice to figure out how to use the commands.
Is there any tutorial for making this work? For instance "write scad for dummy's"? I use open scad in it's most basic form (cube, difference,translate, cylinder, F5, F6, "save as stl" etc) .but don't have a clue how to integrate this to my projects. I should say my file handling skills are right at the edge of marginal. The wrong edge. Do I some how open all these files and then what, paste them into the original openscad program? Or? what??
I downloaded the files listed here and tried just running them to see what happened but get error messages etc. Sorry to be so dumb but I need it in: download write .scad- when openscad opens- download XXX.dxf- copy xxx.dxf and paste it into write.scad. blah, blah, etc. I don't know what "in the same file" means.

Obviously my example above doesn't work but what does without having been through computer school? I do design things in openscad but do not understand "add on routines" or whatever they are called.
Download the Getting Started pdf from above (just added) for some very basic help
I'll create a step by step demo to help get you started.. Are you using PC or Mac?
Have you used OpenSCad?
To new Linux users: This script won't work 'out of the box' as Linux file naming (which OpenSCAD follows) is case sensitive. Therefore to use/include it, you will have to either rename the file Write.scad to write.scad, or change all the use/include statements to Write.scad. Until you do this you will get an error: "WARNING: Can't open 'use' file 'write.scad'."
Otherwise an awesome script!
Just added a new font for write.scad to thingiverse thingiverse.com/thing:101811

And another big thank you to HarlanDMii for write.scad!
For those who rather like to work with Git than with Thingiverse, I am mirroring this thing on GitHub, so you can easily add it as a submodule to your Git-revisioned things: github.com/rohieb/Write.scad

Thanks for this great module, HarlanDMii!
I love this but I'm having trouble with my font, Edwardian Script, in capitals. For some reason some letters (FGHIJV) aren't showing up. Any suggestions. I've uploaded the SVG and DXF to my collection if someone can take a look. Thanks.
Posted a response on you page
Is there any way to write the # sign in Braille?
knape - in reply to knape
I added the number sign to the original braille.dxf
download it here:
https://www.dropbox.com/s/r783nwpzaztlbqz/braille%23.dxf
To all writing in OpenScad: I am looking for a font that has no closed perimeters in its characters.
Reason is that I want to write on one part and exclude from another part so when I merge parts, the text will fit into the hole. When closed perimeters (as in "o" or "B" are used, some parts will not be connected to the printed object.

Is there a font like that for use with "Write" plugin?

rgrds Thomas
http://www.3daybreaker.blogspot.com
Just uploaded a stencil based font, it should be able to hold the inside of the "letters" when printed large enough.
I added a help file for adding fonts. I havent had time to complete the trouble shooting section yet, but I will have it completed soon.
Thanks for that help section, it helped me a lot.
This is a great library. Has anyone created a stencil font for it yet?
I just did.
Just saw the T=option to make it different thicknesses... my bad..
Great tool! Is there a way to change the depth of the letters? It seems locked to 1mm, and I would love to switch it to 2mm.
really cool. very good work.
i have used it already serveral times.
http://www.thingiverse.com/thing:41915

>Be glad to add more fonts if requested, or give details to make your own.
that would be nice if you tell how to create more fonts.
i would like to create symbole fonts.

thanks!
Sorry about the slow reply, I have a major project that has taken a year to complete. I will get detailed instructions on creating fonts posted just as soon as possible.
In case you missed it, write.scad is included in thingiverse.com/apps/customizer Thanks for making a great module. More instructions on making new fonts would be very nice.
How do I use it in the Customizer with my own design?
thingiverse.com/apps/customizer/run?code=f54a0a3ce5cec959eeb2d986d3f37f51

Write.scad use <write write.scad="">

Includes the following fonts:
write/Letters.dxf
write/BlackRose.dxf
write/orbitron.dxf

See thingiverse.com/thing:46335 for an example of how to use write().</write>
Note that for customiser it is case sensitive, must be

include <write write.scad=""></write>
How do you use writecircle to write text, right side up, on the bottom of the circle?
Awesome "thing" you've built! Will save me tons of time building neckerchief slides.

You mentioned that you could either add fonts upon request, or provide instructions on how to add a font. So ... I'm asking.

I'd like some generic monospaced font like Courier and I'd like Arial. I'd be happy to do it myself if you want to provide instructions, or you can do the font thing and
publish them.

One other feature that would help me, but probably isn't very "generic", would be an option to 'touch' the text. In other words, if you set the space to 0 for example, that might signal that each character should just touch the adjacent characters (so they form a continuous chain).
And maybe a negative value for space could indicate how much overlap you wanted.
Thanks,

- Tex
Wow! We should merge our code! I got variable-width fonts working! (Mean OpenSCAD hack)

thingiverse.com/thing:22730
Any way to get numbers to work?
this is great fun. however,

if I use this to write negative (difference the textblock with other shape) thaen some characters will leave unconnected parts.

Would it be possible to design a font that has no closed loops , to be used in {Difference} ??

Thomas
Hi

I'm going to get great use out of your hard work :) thanks

TL:DR use module defaults it just works.

One thing I noticed is most of your examples have translates at the start and one inside your module declaration i.e. cube in your instructions....

From a user stand point I'd suggest looking at
the cube() etc defaults and adding your defaults to match so "this" could work....
cube(30);
writecube("text",size = 30); // or change size to cube

instead of...
(my working example of current module)
cube(30,true);
writecube("text",[0,0,0],size = 30);
(your example in pdf)
translate([10,20,30])
cu
be(30,center=true);
writecube("text",[10,20,30],30);

By change line 231(the writecube module declaration line) to...

module writecube(text = "Hello world" ,where = [0,0,0],size = 50){

You make "this" work...
cube(30,true);
writecube("text",size = 30);

With more consideration you could eliminate
the need to use "true" in the cube command to get the text lined up.
:) Thanks for the suggestions. I made this during the first week I was learning openscad, and havent had much time to update since. Hopefully can back to it soon and make the writecube a little more consistent.
This is positively bizarre, but the capitol A was the only letter not working for me. I looked at Write.scad and found a couple of extra spaces around "a", and when I deleted them, it now works perfectly. No idea why. I changed:

if ((word[r] == "a" )

to

if ((word[r]== "a")
:) Not sure what happened there?? Ill play around with it to see if I can repeat the problem. Thanks for the heads up.
Been messing with this for awhile on both Mac and PC.. The closest I can come to repeating it is from not having the font in the same folder the first time I run it. After that, anything I had already tried to write won't show up until I either re-start OpenSCad or flush the cashes. Wonder if this might be what happened???

The spaces in the script shouldn't make a difference.
This is probably the last update to write.scad for a little while. (unless anyone has some new ideas). Be sure to download the latest write.scad to get all the new commands. Everything that uses any of the old versions is still compatible with the newest one.
Very nice and useful script.

Is there a way to determine the length of the written text?

Something like getTextLength('MyText,h=10,t=4)

And it returns something like 62mm

Thank you
CharacterWidth =(.6875*CharacterHeight*space);

TotalWidth=CharacterWidth*NumCharacters;

Character height is givin in mm.. if not suplied, default value is 4mm
I estimated the character width based on its height. (.6875 of the height)
(space is a scale value to fudge the spacing.. default value is 1)

This help? I will write up a little better description if needed.
This value is calculated in the writesphere module. I could have it echo it in the console if it would help.
width=(.6875*h*space);

totalwidth=width*(len(text)-1);
Thank you!
The test scripts are crashing for me when I try to render in the GUI. At the command line it gives me lots of warnings about unknown function "len" and eventually fails out on "Current top level object is not a 3D object.
AndyP said that he had to update to the latest version of Openscad before it would work on his. The version I am using was released December 2011 so it is a very new release.

openscad.org/
Nice, I struggled to do something similiar and ended up using smallsidefont by br3bttr and integrating it into my scad code as a library. I"ll try yours as a comparison.

See thingiverse thingiverse.com/thing:15753 as an example of how I do it.

How does your text actually look when it is printed out?

Note: I had to update my version of OpenSCAD before some of the commands in write.scad would work.
If you have a chance to test the font on something you print before I get my printer, let me know how it does.

I updated the write.scad this afternoon.. Just replace the the old version with the new version. The usage is still exactly the same.
I havent received my printer yet so I havent had a chance to print. Im hoping to have it soon. I have only been using openscad now for 3 days. Im learning as I go. Some of the commands and lack of real variables is frustrating.I havent seen any documentation on the len command. It was a shot in the dark when I discovered it.
Awesome work! Thank you!!
Thanks. Hoping to have more options soon
Top