A while ago I tried and failed to come up with an easy way to get text into OpenSCAD. The difficulty lies in the fact that OpenSCAD doesn't have complete support for all DXF entities that most tools like autotrace and Inkscape output. This past weekend I wanted to create a simple business card-like object for our hackerspace at Berks CoLab that I could print out and give to people. At first, I was just going to re-design the logo in something else like Sketchup, when I stumbled on this page about other 2D formats in the OpenSCAD manual which suggests using Inkscape to first convert SVG files into EPS files and then using pstoedit to convert the EPS into a DXF that OpenSCAD can read. (woah alphabet soup overload)

Since I had already created the logo using Inkscape, the first thing I wanted to do was to separate out each part of the logo into individual files so that I could extrude the text and shapes in different ways. The first thing you'll want to do is give each object in inkscape a recognizable name by right clicking on it and going to object properties like this:
You'll also want to remove any effects like stroke outlines. I found this ended up causing the final dxf file to cause import problems in OpenSCAD. Next, you'll want to do a File -> Save As and chose EPS, not DXF since Inkscape outputs DXF that OpenSCAD can't process. When you save the EPS a window will come up that lets you limit export to the object with ID that you set in the last step. You'll also want to make sure convert texts to paths and rasterize filter effects is checked on this screen:
Now you'll need pstoedit. I'm on a mac and I use
Mac Ports so all I had to do to install it is "sudo port install pstoedit" on the terminal. Using pstoedit you can convert the EPS file into an OpenSCAD compatible DXF file using this command "pstoedit -dt -f dxf:-polyaslines in.eps out.dxf". Here's the result, I use
eDrawings to view DXF files on OSX:
Now you should be able to extrude the DXF in OpenSCAD. One of the interesting things about cutting up a logo piece by piece like this is that the resulting DXF files import into OpenSCAD exactly where they should go. In other words I exported the circle, the gear, and the words Berks and CoLab as separate objects and when I imported them into OpenSCAD - they all lined up exactly as they were laid out in the original SVG file.
Here's the code I used to extrude just the gear:
color([100/255, 190/255, 50/255]) {
linear_extrude(
file="gear.dxf",
layer="0",
height=5,
scale=20,
origin=[5.85,4.15]
);
}
You'll have to play around with the scale and the origin to get it to be roughly the right size and centered correctly.
I posted all the files used to create the Berks CoLab name tag to thing:5517 or on github. The next thing I'd like to do is make a name tag using green, white, and black plastic as a multipart thing that snaps together like wulfdesign's thing. It should also be possible to write an Inkscape extension that shells out to pstoedit to let you save OpenSCAD compatible DXF files directly from Inkscape - better yet, someone else could do it, plz k thnx!
Just as I was writing this post, I realized my original attempt could now be accomplished with an extra step to create arbitrary text into a 3D printable STL from the command line like so:
convert -size 400x400 -background transparent -fill black -stroke black -gravity center -kerning -30 -font Helvetica-Bold caption:"Tony Buser" tmp.png
autotrace --output-file=tmp.eps tmp.png
pstoedit -dt -f dxf:-polyaslines tmp.eps tmp.dxf
/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -s tmp.stl tmp.scad
I turned it into a simple shell script you can find the code at thing:5518 or better yet on github.
Comments [9]