Convert Your Design Into a 3D Model

This post accompanies a project that I have been working on with my friend Cam Watt. He created a silk screening kit that can be downloaded and printed on a 3D printer. The whole project can be found over at Youmagine.

I spent a week or so trying to convert our logo to a 3D printable file for this project. Each method had quirks. And most of them mostly worked in their own way.

Then I found a script written by Dr. Hank Dietz. In his post he lists a number of different methods and their drawbacks. It's a good read if you're looking for a few more ways to tackle this particular challenge.

If command line is something that you're not comfortable with you should stop reading shortly. But check out Inkscape. There is an extension that converts a vector image to a 3D model. I had a bit of luck with this, but one thing to note is that your shapes have to be fills and not strokes. It will not be able to trace a printable shape out of a single vector.

And now the good stuff.

Trace2SCAD is a shell script that uses sed, awk, ImageMagick, convert, mkbitmap, and potrace. Once I installed all the required dependencies it worked like a charm.

Dependancies

For starters I use a MacBook Pro running OS X Yosemite. I had convert, sed and awk installed already. I'm pretty sure awk and sed are standard fare for Yosemite. It's possibly I installed convert on my own somewhere along the way, but I'm not sure. It's a very hard script name to search the internet for so I'm not sure what to do if your environment doesn't already have it...

You can check to see if you have these using the 'which' command:

As long as it doesn't say '... not found' you should be good to move on.

ImageMagick

Remember when installing imagemagick used to be an afternoon of headaches? Now there is Homebrew. You can find everything you need to get started on their website.

Once Homebrew is all set up just run:

Potrace and mkbitmap

To install potrace you'll need the source file that works on your system. This can then be installed using the usual configure/make commands. This will also install mkbitmap. Two for one!

Click here for step by step instructions for installing potrace.

Ghostscript

During this process I also discovered I needed to install ghostscript. This is also a configure/make installation process. Download the source and follow these installation instructions.

Trace2SCAD

The last piece is trace2scad. The script needs to be located in a folder that you have in your PATH. I have a folder called /scripts in my home directory that I use for just such an occasion:

If you've gotten this far with your setup you are probably familiar enough with your environment to know where to find this. I use zsh and my PATH is defined in ~/.zshrc.

If you're using bash you can also check ~/.profile or ~/.bash_profile. Just add the path to your script folder in your PATH somewhere. Make sure each path is separated by a colon.

The Image File

There are a few things that I've discovered that you will need to know about the image file.

OpenSCAD doesn't like some characters in the model name. To avoid syntax errors keep your file name simple without special characters or spaces.

Something like twofox.png will work while two-fox.png will not. This is because the value of 'prefix' (in the script) will include every character in the file name.

You should also cd into the folder where your image is. If you run the script from further up the file structure you'll get the same syntax error as above. This is because the prefix will include each '/' in the file tree.

The last thing is about the image itself. I tried to convert a transparent PNG a few times. I doesn't work. The image needs a solid background. If you want a nice clean line a high contrast image will work best.

Twofox
Twofox inverted

Remember, if you are using this for silk screening you'll probably need an inverse of your actual graphic. And if you were going to try and make a stamp, you'll have to reverse the image so that the text is legible.

The Magic

There are a lot of options available, but above is all you probably need. The -f (--filter) set to 0 will keep solid area solid. If you're looking for a different effect, check out Dr. Dietz' post for all the options.

The Result

There are a few things you need to render your shape. The script creates a model that is 1mm x 1mm x 1mm. This is clearly too small for anything useful so you'll have to bump that up for your needs. At the bottom of your new SCAD file you'll find the module that will render your file.

After the trace the last module of my file mine looked like this:

First, increase the scale to meet your needs. In this case we will be printing this onto a screen of 124mm by 124mm and only 0.2mm thick:

And, of course, to render it all into OpenSCAD you'll have to call the module. I just added this to the end of the file:

Twofox3d

That's it!

Huge shout out to Dr. Hank Dietz for publishing this script literally 10 days before I needed something just like it. And of course to Cam who an endless catalyst for all these crazy ideas.


February 7, 2015 3D printing, OpenSCAD
Pow

Jamie calls Hamilton, Ontario home. He spends his weekdays working for factor[e] design initiative making the internet a little more user friendly and the rest of his time with his special lady friend. He enjoys long walks on the beach and organizing things neatly.


Add a Comment