0% found this document useful (0 votes)
170 views

Openscad Manual 8

This document discusses different parameters and techniques for extruding 2D shapes in OpenSCAD to create 3D objects. It explains linear extrusion, rotational extrusion, and importing 2D files like DXF to extrude. Key parameters for extrusion include height, center, twist, slices, scale, and convexity. It also provides tips for converting between file formats like SVG, EPS, and DXF for use in OpenSCAD extrusion.

Uploaded by

keeyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

Openscad Manual 8

This document discusses different parameters and techniques for extruding 2D shapes in OpenSCAD to create 3D objects. It explains linear extrusion, rotational extrusion, and importing 2D files like DXF to extrude. Key parameters for extrusion include height, center, twist, slices, scale, and convexity. It also provides tips for converting between file formats like SVG, EPS, and DXF for use in OpenSCAD extrusion.

Uploaded by

keeyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

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

linear_extrude(height = 10, center = true, convexity = 10, twist = -500)


translate([2, 0, 0])
circle(r = 1);

center = false

linear_extrude(height = 10, center = false, convexity = 10, twist = -500)

79 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

translate([2, 0, 0])
circle(r = 1);

Mesh Refinement

The slices parameter can be used to improve the output.

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)

80 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

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);

81 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

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

A simple torus can be constructed using a rotational extrude.

82 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

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);

The number of fragments used by the extrusion can also be increased.

83 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

rotate_extrude(convexity = 10, $fn = 100)


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.

rotate([90,0,0]) polygon( points=[[0,0],[2,1],[1,2],[1,3],[3,4],[0,5]] );

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.

rotate_extrude($fn=200) polygon( points=[[0,0],[2,1],[1,2],[1,3],[3,4],[0,5]] );

84 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

For more information on polygons, please see: 2D Primitives: Polygon.

Description of extrude parameters

Extrude parameters for all extrusion modes

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.

Extrude parameters for linear extrusion only

height The extrusion height


center If true the solid will be centered after extrusion
twist The extrusion twist in degrees
slices Similar to special variable $fn without being passed down to the child 2D shape.
scale Scales the 2D shape by this value over the height of the extrusion.

85 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

With the import() and extrusion statements it is possible to convert 2D objects read from
DXF files to 3D objects.

Linear Extrude

Example of linear extrusion of a 2D object imported from a DXF file.

linear_extrude(height = fanwidth, center = true, convexity = 10)


import (file = "example009.dxf", layer = "fan_top");

Rotate Extrude

Example of rotational extrusion of a 2D object imported from a DXF file.

rotate_extrude(convexity = 10, twist = -fanrot)


import (file = "example009.dxf", layer = "fan_side", origin = fan_side_center);

Getting Inkscape to work

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)

Description of extrude parameters

Extrude parameters for all extrusion modes

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]

Extrude parameters for linear extrusion only

86 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

height The extrusion height


center If true, extrusion is half up and half down. If false, the section is extruded up.
twist The extrusion twist in degrees
slices FIXME

Currently, OpenSCAD only supports DXF as a graphics format for 2D graphics. Other
common formats are PS/EPS and SVG.

PS/EPS

The pstoedit (http://www.pstoedit.net/) program can convert between various vector


graphics formats. OpenSCAD needs the -polyaslines option passed to the dxf output plugin
to understand the file. The -dt options instructs pstoedit to render texts, which is usually
what you want if you include text. (If the rendered text's resolution in terms of polygon
count is too low, the easiest solution is to scape up the eps before converting; if you know a
more elegant solution, please add it to the example.)

pstoedit -dt -f dxf:-polyaslines infile.eps outfile.dxf

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.

inkscape -E intermediate.eps infile.svg


pstoedit -dt -f dxf:-polyaslines intermediate.eps outfile.dxf

Makefile automation

The conversion can be automated using the make system; put the following lines in your
Makefile:

all: my_first_file.dxf my_second_file.dxf another_file.dxf

%.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

87 sur 128 11/03/2014 10:03


OpenSCAD User Manual/Print version - Wikibooks, o... http://en.wikibooks.org/w/index.php?title=OpenSCA...

ending in .eps, and the third from .eps to .dxf.

STL Import and Export


Import and Export
A prime ingredient of any 3D design flow is the ability to import from and export to other
tools. The STL file format (http://en.wikipedia.org/wiki/STL_(file_format)) is currently the
most common format used.

Import
import

Imports a file for use in the current OpenSCAD model

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:

CGAL error in CGAL_Build_PolySet: CGAL ERROR: assertion violation!

Expr: check_protocoll == 0

File: /home/don/openscad_deps/mxe/usr/i686-pc-mingw32/include
/CGAL/Polyhedron_incremental_builder_3.h

Line: 199

or

88 sur 128 11/03/2014 10:03

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy