OpenSCAD User Manual/2D to 3D Extrusion
Extrusion is the process of creating an object with a fixed cross-sectional profile. OpenSCAD provides two commands to create 3D solids from a 2D shape: linear_extrude() and rotate_extrude(). Linear extrusion is similar to pushing Playdoh through a press with a die of a specific shape.

Rotational extrusion is similar to the process of turning or "throwing" a bowl on the Potter's wheel.
Both extrusion methods work on a (possibly disjointed) 2D shape which exists on the X-Y plane. While transformations that operates on both 2D shapes and 3D solids can move a shape off the X-Y plane, when the extrusion is performed the end result is not very intuitive. What actually happens is that any information in the third coordinate (the Z coordinate) is ignored for any 2D shape, this process amounts to an implicit projection() performed on any 2D shape before the extrusion is executed. It is recommended to perform extrusion on shapes that remains strictly on the X-Y plane.
linear_extrude
A Linear Extrusion must be given a 2D child object. This child object is first projected onto the X-Y plane along the Z axis to create the starting face of the extrusion. The start face is duplicated at the Z position given by the height parameter to create the extrusion's end face. The extrusion is then formed by creating a surface that joins each point along the edges of the two faces.
The 2D shape may be any 2D primitive shape, a 2d polygon, or a combination of them. The 2D shape may have a Z value that moves it out of the X-Y plane, and it may even be rotated out of parallel with it. As stated above, the extrusion's starting face is the projection of the 2D shape onto the X-Y plane, which, if it is rotated, will have the effect of fore-shortening it normal to the axis of the rotation.
Using a 3D object as the extrusion's child will cause a compile time error. Including a 3D object in a composite of 2D objects (using union or difference) will be detected, the 3D object(s) will be deleted from it and the remaining 2D objects will be the basis for projecting their shape onto the X-Y plane.
Parameters For Linear Extrusion
- height
- a non-negative integer, default 100, giving the length of the extrusion
- center
- a boolean, default false, that, when true, causes the resulting solid to be vertically centered at the X-Y plane.
- convexity
- a non-negative integer, default 1, giving a measure of the complexity of the generated surface. See the Section on Convexity later on this page.
- twist
- a signed decimal, default 0.0, specifying how many degrees of twist to apply between the start and end faces of the extrusion. 180 degrees is a half twist, 360 is all the way around, and so on.
- v - twist axis vector
- a vector of 3 signed decimal values, default [0,0,1], used as an eigen vector specifying the axis of rotation for the twist. [Note: Requires version Development snapshot]
- scale
- a non-negative, decimal value, default 1.0, greater than 0.0, that specifies the factor by which the end face should be scaled up, or down, in size from that of the start face.
- a vector containing these values in this order
- [
- slices
- a non-negative integer value that acts on the extruded surface as $fn does, but which is not applied to the child 2D shape.
- segments
- Similar to slices but adding points on the polygon's segments without changing the polygon's shape.
- $fn
- the special variable but applied only to the extrusion
- $fs
- the special variable but applied only to the extrusion
- $fa
- the special variable but applied only to the extrusion
- ]
Notes
- centering the extrusion only affects its vertical position. Its X-Y position is always set by the projection of its starting face.
- A Scale Factor greater than one increases the size of the extrusion's end face, while a value greater than 0.0 and less than 1 shrink it. A value of 0.0 causes the end face to degenerate to a point, turning the extrusion into a pyramid, cone, or complex pointy shape according to what the starting shape is.
- the twist is applied, by default, as a rotation about the Z Axis. When the start face is at the origin a twist creates a spiral out of any corners of the child shape. If the start face is translated away from the origin the twist creates a spring shape.
- positive twist rotates clockwise, negative twist the opposite.
- when the twist axis vector "v" is tilted away from the Z axis the twist is applied between the start and end faces without making them normal to the axis. They remain as flat shapes parallel to the X-Y plane and the twisted surfaces are thus distorted from what they would be normally. To have it otherwise it would be necessary to form the twisted extrusion on the Z Axis and then rotate it into position.
- all the parameters need to be given as named as the addition of the "v" vector parameter causes a error when only positional parameters are given
A Unit Circle with No Twist
Generate an extrusion from a circle 2 units along the X Axis from the origin, centered vertically on the X-Y plane, with no twist. The extrusion appears to have a pentagonal cross-section because the extrusion's child is a 2D circle with the default value for $fn.
linear_extrude(height = 10, center = true, convexity = 10, twist = 0) translate([2, 0, 0]) circle(r = 1);
A Unit Circle Twisted Left 100 Degrees
The same circle, but now with 100 degrees of counter-clockwise twist.
linear_extrude(height = 10, center = true, convexity = 10, twist = -100) translate([2, 0, 0]) circle(r = 1);
A Unit Circle Twisted Right 100 Degrees
The same circle, but now with 100 degrees of clockwise twist.
linear_extrude(height = 10, center = true, convexity = 10, twist = 100) translate([2, 0, 0]) circle(r = 1);
A Unit Circle Twisted Into a Spiral
The same circle, but made into a spiral by 500 degrees of counter-clockwise twist.
linear_extrude(height = 10, center = true, convexity = 10, twist = -500) translate([2, 0, 0]) circle(r = 1);
Center
With center=false
, the default, the extrusion is based on the X-Y plane and rises up in the positive Z direction.
When true it is centered vertically at the X-Y plane, as seen here:
Mesh Refinement
The slices parameter defines the number of intermediate points along the Z axis of the extrusion. Its default increases with the value of twist. Explicitly setting slices may improve the output refinement. Additional the segments parameter adds vertices (points) to the extruded polygon resulting in smoother twisted geometries. Segments need to be a multiple of the polygon's fragments to have an effect (6 or 9.. for a circle($fn=3), 8,12.. for a square() ).
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. If slices is not defined, its value is taken from the defined $fn value.
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:
linear_extrude(height = 10, center = true, convexity = 10, scale=3) translate([2, 0, 0]) circle(r = 1);
linear_extrude(height = 10, center = true, convexity = 10, scale=[1,5], $fn=100) translate([2, 0, 0]) circle(r = 1);
Note that if scale is a vector, the resulting side walls may be nonplanar. Use twist=0
and the slices
parameter to avoid asymmetry.
linear_extrude(height=10, scale=[1,0.1], slices=20, twist=0) polygon(points=[[0,0],[20,10],[20,-10]]);
Using with imported SVG
A common usage of this function is to import a 2D svg
linear_extrude(height = 10, center = true) import("knight.svg");
rotate_extrude
Rotational extrusion spins a 2D shape around the Z-axis to form a solid which has rotational symmetry. One way to think of this operation is to imagine a Potter's wheel placed on the X-Y plane with its axis of rotation pointing up towards +Z. Then place the to-be-made object on this virtual Potter's wheel (possibly extending down below the X-Y plane towards -Z). The to-be-made object is the cross-section of the object on the X-Y plane (keeping only the right half, X >= 0). That is the 2D shape that will be fed to rotate_extrude() as the child in order to generate this solid. Note that the object started on the X-Y plane but is tilted up (rotated +90 degrees about the X-axis) to extrude.
Since a 2D shape is rendered by OpenSCAD on the X-Y plane, an alternative way to think of this operation is as follows: spins a 2D shape around the Y-axis to form a solid. The resultant solid is placed so that its axis of rotation lies along the Z-axis.
Just like the linear_extrude, the extrusion is always performed on the projection of the 2D polygon to the XY plane. Transformations like rotate, translate, etc. applied to the 2D polygon before extrusion modify the projection of the 2D polygon to the XY plane and therefore also modify the appearance of the final 3D object.
- A translation in Z of the 2D polygon has no effect on the result (as also the projection is not affected).
- A translation in X increases the diameter of the final object.
- A translation in Y results in a shift of the final object in Z direction.
- A rotation about the X or Y axis distorts the cross section of the final object, as also the projection to the XY plane is distorted.
Don't get confused, as OpenSCAD displays 2D polygons with a certain height in the Z direction, so the 2D object (with its height) appears to have a bigger projection to the XY plane. But for the projection to the XY plane and also for the later extrusion only the base polygon without height is used.
You cannot use rotate_extrude to produce a helix or screw thread. Doing this properly can be difficult, so it's best to find a thread library to make them for you.
The 2D shape must lie completely on either the right (recommended) or the left side of the Y-axis. More precisely speaking, every vertex of the shape must have either x >= 0 or x <= 0. If the shape spans the X axis a warning appears in the console windows and the rotate_extrude() is ignored. If the 2D shape touches the Y axis, i.e. at x=0, it must be a line that touches, not a point, as a point results in a zero thickness 3D object, which is invalid and results in a CGAL error. For OpenSCAD versions prior to 2016.xxxx, if the shape is in the negative axis the resulting faces are oriented inside-out, which may cause undesired effects.
Usage
rotate_extrude(angle = 360, start=0, convexity = 2) {...}

In 2021.01 and previous, you must use parameter names due to a backward compatibility issue.
- convexity : If the extrusion fails for a non-trival 2D shape, try setting the convexity parameter (the default is not 10, but 10 is a "good" value to try). See explanation further down.
- angle [Note: Requires version 2019.05] : Defaults to 360. Specifies the number of degrees to sweep, starting at the positive X axis. The direction of the sweep follows the Right Hand Rule, hence a negative angle sweeps clockwise.
- start [Note: Requires version Development snapshot] : Defaults to 0 if angle is specified, and 180 if not. Specifies the starting angle of the extrusion, counter-clockwise from the positive X axis.
- $fa : minimum angle (in degrees) of each fragment.
- $fs : minimum circumferential length of each fragment.
- $fn : fixed number of fragments in 360 degrees. Values of 3 or more override $fa and $fs
- $fa, $fs and $fn must be named parameters. click here for more details,.
Examples

A simple torus can be constructed using a rotational extrude.
rotate_extrude(convexity = 10) translate([2, 0, 0]) circle(r = 1);
Mesh Refinement

Increasing the number of fragments composing the 2D shape improves the quality of the mesh, but takes longer to render.
rotate_extrude(convexity = 10) translate([2, 0, 0]) circle(r = 1, $fn = 100);

The number of fragments used by the extrusion can also be increased.
rotate_extrude(convexity = 10, $fn = 100) translate([2, 0, 0]) circle(r = 1, $fn = 100);
Using the parameter angle (with OpenSCAD versions 2016.xx), a hook can be modeled .

eps = 0.01; translate([eps, 60, 0]) rotate_extrude(angle=270, convexity=10) translate([40, 0]) circle(10); rotate_extrude(angle=90, convexity=10) translate([20, 0]) circle(10); translate([20, eps, 0]) rotate([90, 0, 0]) cylinder(r=10, h=80+eps);
Extruding a Polygon
Extrusion can also be performed on polygons with points chosen by the user.
Here is a simple polygon and its 200 step rotational extrusion. (Note it has been rotated 90 degrees to show how the rotation appears; the rotate_extrude()
needs it flat).
rotate([90,0,0]) polygon( points=[[0,0],[2,1],[1,2],[1,3],[3,4],[0,5]] );
rotate_extrude($fn=200) polygon( points=[[0,0],[2,1],[1,2],[1,3],[3,4],[0,5]] );

For more information on polygons, please see: 2D Primitives: Polygon.
Orientation
If you're making a round 360 degree extrusion, it doesn't matter where it starts. If, on the other hand, you're using $fn to make an extrusion with some specific number of sides, it can matter. With an odd number of sides, there will be a vertex on either the left or the right, and a side opposite it.
With angle not specified, the extrusion starts along the negative X axis, to the left of the origin. With an odd number of sides, there is a vertex on the left and a side on the right. (Note that this is inconsistent with the behavior for angle less than 360, and with the behavior for circle and other round primitives.)
With angle specified, and not equal to 360, the extrusion starts along the positive X axis, to the right of the origin.
For 2021.01 and earlier, if angle is equal to 360, the extrusion starts along the negative X axis, as for angle not being specified.
For the development snapshot, if angle is 360, the extrusion starts along the positive X axis, as for other cases where angle is specified. Explicitly specifying angle=360 thus yields results consistent with other round primitives.
A future release may change this behavior so that when angle is not specified the extrusion starts along the positive X axis, making all of these cases consistent.
start directly controls the start point. [Note: Requires version Development snapshot]
Description of extrude parameters
Parameters Used In All Extrusions
- convexity
- an integer that works as a measure of complexity based on the maximum number of sides a ray might penetrate as it passes through a shape.
OpenSCAD uses OpenCSG to render objects in preview mode using the Goldfeather algorithm which takes account of convexity to calculate which parts of a shape to render. The algorithm that generates the mesh for the full rendering operation uses a different method so this parameter that ignores convexity.
The preview render works by presuming an eye point from which rays are emitted towards the objects in view, which are then reflected back to the eye point with information about what to display in each pixel. When a shape may have parts hidden from view by a fold or opening the preview algorithm must process along each ray until it can be sure that it it has processed all the surfaces that the eye might see from its view point.
The details of how convexity is used are fully explained on the OpenCSG site in the Usage section but the gist is that the algorithm needs to be informed that it must work harder on more complex shapes. For instance, the convexity of a sphere is one and the convexity of a torus is two. It is certainly possible that from some view points every ray from the eye faces only a single surface, which is certainly true for the sphere. But from a viewpoint well off the torus central axis rays can pass through its front and back parts so a given pixel may need to show the front most face, or the back part of the doughnut, or the background. A value of convexity greater than the default 1 informs the renderer of the need to be more careful in its work.
This 2D shape has a convexity of 2, as there is at least one ray (the red line) that passes through its boundary twice on its way to or from the eye point. If convexity was at the default 1 the rendering process would stop at the first crossing and the possibility of that pixel needing to show the crossing at the other surface will not be evaluated, leading to faults in the preview image.
3D shapes are evaluated in the same way, higher convexity being needed when a ray might pass through many internal surfaces on its way to the view point. Arbitrarily setting convexity to 10 should solve most preview rendering issues, at the expense of slowing preview rendering. When a model has several convoluted shapes values more than 15 can slow rendering to the point of freezing the application.
Parameters For Linear Extrusion
- height
- a non-negative integer, default 100, giving the length of the extrusion
- center
- a boolean, default false, that, when true, causes the resulting solid to be vertically centered at the X-Y plane.
- twist
- a signed decimal, default 0.0, specifying how many degrees of twist to apply between the start and end faces of the extrusion
- scale
- a non-negative, decimal value, default 1.0, greater than 0.0, that specifies the factor by which the end face should be scaled up, or down, in size from that of the start face.
- a vector containing these values in this order
- [
- slices
- a non-negative integer value that acts on the extruded surface as $fn does, but which is not applied to the child 2D shape.
- segments
- Similar to slices but adding points on the polygon's segments without changing the polygon's shape.
- $fn
- the special variable but applied only to the extrusion
- $fs
- the special variable but applied only to the extrusion
- $fa
- the special variable but applied only to the extrusion
- ]
Note
- centering the extrusion only affects its vertical position. Its X-Y position is always set by its starting face.
- A Scale Factor greater than one increases the size of the extrusion's end face, while a value greater than 0.0 and less than 1 shrink it. A value of 0.0 causes the end face to degenerate to a point, turning the extrusion into a pyramid, cone, or complex pointy shape according to what the starting shape is.