In this OpenSCAD tutorial series so far we’ve covered the basics of the OpenSCAD interface, how to make 2D forms, how to make some basic 3D forms, how to position those forms in 3D space, the different ways to combine forms, how to create mashups of one or more existing STL’s and OpenSCAD forms, and how to use modules to reuse your code to make your life easier. Although I described the last three tutorials as “intermediate” levels, that’s really only because you learned the basics so quickly from the first few tutorials. With just the basics you can literally design anything you can imagine. The “intermediate” lessons will let you do a little more and make your life a lot easier.
Before we get started, the image is from BoriSpider‘s OpenSCAD tutorial homework. I’d like to include a picture of your homework next time. So, please practice making something in OpenSCAD, upload it to Thingiverse with an open license, and tag it with “openscadtutorial.”
- You may remember one of the first tutorials was about creating flat 2D forms using some simple commands. Once you learned how to make 3D objects, it probably didn’t seem very interesting to play with the square, circle, and polygon commands. However, there are still a lot of uses for these flat objects. OpenSCAD gives us the ability to do some very interesting things with flat objects by giving them a third dimensional quality – thickness.
- The “linear_extrude” command will let us basically take a flat object and give it thickness. First, let’s take a basic object like a rectangle.
- Now, let’s use the “linear_extrude” command to give this rectangle a thickness of 13mm.
- linear_extrude(height = 13) square([20,30]);
- You can even use this on a pile of flat objects or a module of flat objects.
- module flatstuff()
- translate([10,20,0]) circle(10);
- translate([20,10,0]) circle(10);
- linear_extrude(height = 13) flatstuff();
- If you’ve mastered “linear_extrude” you’re ready for a pretty easy and useful way to extrude DXF files. A DXF file is a digital file commonly used on Thingiverse and elsewhere for laser cutting. A DXF is basically a flat 2D drawing where the path of the 2D lines would b ecut by a laser or some other cutting method.
- Let’s imagine you have a 3D printer – but no laser cutter. Perhaps you’ve just found something amazing on Thingiverse for laser cutting, but you just can’t live without it. Or, perhaps you want to print a replacement laser cut part for your 3D printer. You can use the OpenSCAD “dxf_linear_extrude” command to work in much the same way as the above “linear_extrude” command.
- Assuming your DXF file is in the same folder as your OpenSCAD installation, the following should work for you too:
- dxf_linear_extrude(file=”pandorica13.dxf”, height=2);
- Now instead of just a 2D outline of the image in the DXF file, you should have a 2mm thick object in the shape of your DXF!
- Just so you know, OpenSCAD can be little finicky about the DXF files it imports. It will need to be in “DXF R12″ format, otherwise it might use certain DXF features that aren’t supported by OpenSCAD.
- Since “rotate_extrude()” does something similar and has similar syntax, this would be a good time to cover it as well. This command basically takes a flat object and spins in 360 degrees around the Z axis. Let’s take a circle and see what happens when we spin it.
- circle(r = 10);
- As you might expect, it turns a circle into a sphere.
- Let’s see what happens when we offset that circle a little bit.
- circle(r = 10);
- You should now see a great big donut. Since the circle is offset from the center of the Z axis, when it gets spun around the axis, it will leave a hole in the middle.
Now that you’ve learned how to use three different kinds of extrusion in OpenSCAD, how about showing everyone what you can do? See if you can find a DXF file on Thingiverse and extrude it into a part you could actually print. When you’re done, upload your OpenSCAD file and the STL to Thingiverse. As always, to make me extra proud be sure and tag it with “openscadtutorial.” As if basking in my affection wasn’t enough, I’ll pick one someone’s OpenSCAD homework and use their designs as part of the next tutorial.
Bonus Section 1: The Tutorials So Far
Bonus Section 2: Other sources
If you like reading ahead or want more information about OpenSCAD, I’ve found these websites to be very helpful.
- Official OpenSCAD website
- OpenSCAD User’s Manual
- OpenSCAD beginner’s tutorial
- OpenSCAD tutorial roundup on the Thingiverse blog
- Inkscape to OpenSCAD DXF tutorial
Bonus Section 3: What’s next???
The topic of the next tutorial is up to you. What would you like to learn next? Is there something you’d like to learn how to make? Is there something more you’d like to learn about some of the topics we’ve covered?