Graphics Reference
In-Depth Information
OpenSCAD's DXF importer is based on the file specification for AutoCAD R12.
This means that all shapes in the file need to be closed shapes that are drawn
without using polylines or splines, or you will get OpenSCAD errors or unin-
tended results.
To begin, you need a properly formatted DXF file. You can go about this in a
few different ways:
• If you already have AutoCAD or other high end DXF creation software,
you can create your model as you normally would then export the file as
an AutoCAD DXF revision 12 (R12) file.
• Inkscape (with extensions) will export acceptable DXF files.
• You can use the
pstoedit
command line tool to convert files saved as
EPS to DXF format.
If you just want to test out
linear_extrude
without creating
your own files, you can download the files used in the MakerBot
Coin code from Thingiverse (
http://www.thingiverse.com/
thing:36167
)
.
Before we launch into file conversion methods, let's explore how DXF extru-
sion works. The
linear_extrude
child import
function in OpenSCAD enables
us to import single or multiple DXF files and extrude them. By specifying the
height parameter for
linear_extrude
and the file parameter for import, you
can add depth/height to any file.
In previous versions of OpenSCAD, linear_extrude had a dif-
ferent function name for extruding DXF files,
dxf_linear_ex
trude
. This feature has been depreciated and replaced with
the
child import
syntax shown in the code example. However,
if you are digging further into this feature, you will often see
dxf_linear_extrude
used in code on Thingiverse and in other
online tutorials.
Here is a basic example that creates a MakerBot logo coin, shown in
Figure C-8
by using linear_extrude() to extrude two different DXF files:
union(){
linear_extrude(height=7) import(file = "MakerbotM.dxf");
linear_extrude(height=2) import(file = "MakerbotM_Base.dxf");
}