Introduction: Print a 3D Key Fob From an Image or Logo
Let's say, hypothetically, that you need to design a 3D printable key fob for an event this weekend. First you check Instructables and Thingiverse to see if anyone has done it already. Unfortunately no one has, so you come back and read this Instructable. Don't worry, though, it's not that difficult. This basically involves converting a black and white image to vector format and extruding it into a 3D shape.
Through the process of modelling a key fob, students will be able to explore a practical application of geometry and algebra.
Instructors can also take this opportunity to remind students about the importance of respecting intellectual property, trademarks, and copyright.
Step 1: Software and Hardware Requirements
For converting the image to a vector graphic, we'll use Inkscape (with the Better DXF plugin or R12 plugin).
To extrude the vector graphic into 3D and add the key ring attachment we'll use OpenSCAD.
Preparing the file for printing will involve ReplicatorG or similar software.
Making a physical model will require a 3D Printer (e.g. MakerBot) or a service such as Shapeways.
Step 2: Setting Up Inkscape and "Better DXF Output"
Download and install Inkscape from inkscape.org. If you're running Windows you can use the installable or portable (no install required) version.
To install the "Better DXF Output" extension, download the file better_dxf_output.zip. Extract the three files and put them in "C:\Program Files\Inkscape\share\extensions" (if you installed the Windows version) or "...\InkscapePortable\App\Inkscape\share\extensions" (if you're using the Windows portable version) or "usr/share/inkscape/extensions" (if you installed the Linux version).
Start up Inkscape and you should now be able to save drawings as "Better DXF Output" files. We need to use this extension because OpenSCAD requires R12 DXF files, and Inkscape 0.48 and newer exports R13 DXF files.
Step 3: Converting the Image to a Vector Graphic
This is probably the most difficult part, but it shouldn't be too hard. We're going to import the logo into Inkscape, trace it, clean it up if necessary, and export it as a DXF file for the next step. If you already have a (R12) DXF file of your logo, you can skip this step.
1. Under the File menu chose Import... and select your logo file. Hopefully it's a single colour (e.g. black and white) bitmap.
2. Click on your logo, then under the Path menu choose Trace Bitmap...
3. On the dialogue box that comes up, click OK and then close it. If all goes well you should now have a path object above your original bitmap.
4. Move the path object out of the way, and delete the original bitmap. Move the path object back to the bottom left (0, 0).
5. If there are parts of the image that you don't want, under the Path menu choose Break Apart and delete the unwanted parts
6. Select everything that remains and under the Path menu choose Combine.
7. Resize the path object to the size you'd like your key fob to be by typing the size in the W (width) or H (height) box. Make sure your click the lock button first to make sure you don't change the aspect ratio of your logo.
8. Under the File menu choose Save As... then choose Better DXF Output (*.DXF) from the dropdown menu. Name your file logo.DXF and remember when you save it so that you can use it for the next step.
Step 4: Creating a 3D Model
Now that you have a DXF file of your logo, we need to make it 3D.
Go to OpenSCAD.org to download the program for Linux, OS X, or Windows and install (or unzip and run the portable version).
Run OpenSCAD and paste in the following code (or download the attached logo.scad file).
width = 50; // the x size of the logo
length = 40.572; // the y size of the logo
logodepth = 2; // how far in the z direction you want the logo extruded
backdepth = 1; // thinckness of the back of the key fob
padding = 3; // how far from the edge you want the logo
holewidth = 10; // the size of the ring attachment on the top
color("green") translate(v = [0, 0, backdepth]) linear_extrude(height = logodepth) import(file = "logo.DXF"); // importing and extruding the logo
minkowski() // this is a transformation that adds a second shape (the cylinder) around the outside of the first shape (the cube)
cube([width, length, backdepth/2]); // a cube to go behind the logo
cylinder(r=padding, h=backdepth/2); // rounding the corners of the cube
translate(v = [width/2, length+padding, 0]) cylinder(h = backdepth, r = holewidth/2); // the outside of the key ring attachment
translate(v = [width/2, length+padding, -1]) cylinder(h = backdepth+logodepth+2, r = holewidth/2-2); // cut out the inside of the key ring attachement
cube([width, length, backdepth+logodepth+2]); // cut out so that we don't overlap with the logo
Step 5: Rendering the 3D File
Make sure your logo.DXF file from the previous step is in the same folder as the OpenSCAD program, or specify the location in the import(file = "logo.DXF") line.
Put in appropriate values for the variables at the top of the code (width, length, etc.).
Under the Design menu select (or press F5) and it will show you what your design looks like.
Under the Design menu select Compile and Render (CGAL) (or press F6) and it will create a rendering of your design. Then select Export as STL... under the Design menu to save your completed 3D model in a format that can be used for printing.
Step 6: Printing Your 3D Model
Now that you have an STL file of your 3D model you can generate G-code and print as you normally would (likely using ReplicatorG), or you can order a printed part from an online service such as Shapeways.
The first time I made key fobs we needed 90 copies for a series of sessions I was teaching, the MakerBot Automated Build Platform was very useful for this.