Openscad Manual 8
Openscad Manual 8
Center determines if the object is centered after extrusion, so it does not extrude up and
down from the center as you might expect.
center = true
center = false
translate([2, 0, 0])
circle(r = 1);
Mesh Refinement
linear_extrude(height = 10, center = false, convexity = 10, twist = 360, slices = 100)
translate([2, 0, 0])
circle(r = 1);
The special variables $fn, $fs and $fa can also be used to improve the output.
linear_extrude(height = 10, center = false, convexity = 10, twist = 360, $fn = 100)
translate([2, 0, 0])
circle(r = 1);
Scale
Scales the 2D shape by this value over the height of the extrusion. Scale can be a scalar or a
vector:
Rotate Extrude
A rotational extrusion is a Linear Extrusion with a twist, literally. Unfortunately, it can not
be used to produce a helix for screw threads as the 2D outline must be normal to the axis of
rotation, ie they need to be flat in 2D space.
Examples
rotate_extrude(convexity = 10)
translate([2, 0, 0])
circle(r = 1);
Mesh Refinement
Increasing the number of fragments that the 2D shape is composed of will improve the
quality of the mesh, but take longer to render.
rotate_extrude(convexity = 10)
translate([2, 0, 0])
circle(r = 1, $fn = 100);
Extruding a Polygon
Extrusion can also be performed on polygons with points chosen by the user.
Here is a simple polygon. Note it has been rotated 90 degrees to show how the rotation will
look, the rotate_extrude() needs it flat.
Here is the same polygon, rotationally extruded, and with the mesh refinement set to 200.
The polygon must touch the rotational axis for the extrusion to work, i.e. you can't build a
polygon rotation with a hole.
Integer. The convexity parameter specifies the maximum number of front sides
(back sides) a ray intersecting the object might penetrate.
convexity
This parameter is only needed for correctly displaying the object in OpenCSG
preview mode and has no effect on the polyhedron rendering.
This image shows a 2D shape with a convexity of 4, as the ray indicated in red crosses the
2D shape a maximum of 4 times. The convexity of a 3D shape would be determined in a
similar way. Setting it to 10 should work fine for most cases.
With the import() and extrusion statements it is possible to convert 2D objects read from
DXF files to 3D objects.
Linear Extrude
Rotate Extrude
Inkscape is an open source drawing program. Tutorials for transferring 2d DXF drawings
from Inkscape to OpenSCAD are available here:
http://repraprip.blogspot.com/2011/05/inkscape-to-openscad-dxf-tutorial.html (Very
simple)
http://tonybuser.com/?tag=inkscape (More complicated, involves conversion to
Postscript)
http://www.damonkohler.com/2010/11/inkscape-dxf-openscad-makerbot.html (Better
Better DXF Plugin for Inkscape)
scale FIXME
convexity See 2D to 3D Extrusion
file The name of the DXF file to extrude [DEPRECATED]
layer The name of the DXF layer to extrude [DEPRECATED]
[x,y] coordinates to use as the drawing's center, in the units specified in the
origin
DXF file [DEPRECATED]
Currently, OpenSCAD only supports DXF as a graphics format for 2D graphics. Other
common formats are PS/EPS and SVG.
PS/EPS
SVG
pstoedit does not understand SVG, but EPS can be converted from an SVG. inkscape
(http://inkscape.org), an SVG editor, can be used for conversion.
Makefile automation
The conversion can be automated using the make system; put the following lines in your
Makefile:
%.eps: %.svg
inkscape -E $@ $<
%.dxf: %.eps
pstoedit -dt -f dxf:-polyaslines $< $@
The first line specifies which dxf files are to be generated when make is called in the current
directory. The second paragraph specifies how to convert a file ending in .svg to a file
Import
import
Parameters
<file>
A string containing the path to the STL or DXF file.
Usage examples:
import("example012.stl");
Notes: In the latest version of OpenSCAD, import() is now used for importing both 2D (DXF
for extrusion) and 3D (STL) files.
If you want to render the imported STL file later, you have to make sure that the STL file is
"clean". This means that the mesh has to be manifold and should not contain holes nor
self-intersections. If the STL is not clean, you might get errors like:
Expr: check_protocoll == 0
File: /home/don/openscad_deps/mxe/usr/i686-pc-mingw32/include
/CGAL/Polyhedron_incremental_builder_3.h
Line: 199
or