OpenSCAD User Manual/SVG Import
SVG Import[edit | edit source]
[Note: Requires version 2019.05]
OpenSCAD can import the geometric structure of SVG files.
import("file.svg"); import(file = "file.svg", center = false, dpi = 96); import("file.svg", $fn = 100); // [Note: Requires version Development snapshot]
- String. The name of the file to import.
- Boolean. If set to true, the imported geometry is centered by bounding box of the geometry.
- Double. Use this DPI value for calculating the size of the viewbox if no unit is given for width/height. If no width/height is given at all the viewbox is used instead (e.g. for files created with older versions of Adobe Illustrator). If an absolute unit is given for width/height (px/pt/pc/in/mm/cm) the DPI value is ignored.
- Double. The number of polygon segments to use when converting circles, arcs, and curves to polygons. [Note: Requires version Development snapshot]
- Double. The minimum angle step to use when converting circles and arcs to polygons. [Note: Requires version Development snapshot]
- Double. The minimum segment length to use when converting circles and arcs to polygons. [Note: Requires version Development snapshot]
- String. The id of an element or group to import. [Note: Requires version Development snapshot]
- String. The layer to import. This specifically uses the Inkscape layer names using the `inscape:label` attribute. [Note: Requires version Development snapshot]
Limitations[edit | edit source]
Scalable Vector Graphics (SVG), as the name already implies, is designed to be a scalable graphics format targeting rendering on Web pages with support for interactivity and animation.
This means there are a number of features that do not translate well into the use as CAD format. Especially all animation features and most visual properties in the SVG file are ignored. In general the OpenSCAD SVG import extracts the core geometric information of the objects and transforms that into closed 2D polygons.
Main features not imported are:
- Text / Fonts
- Clipping and Masking
- Objects using templates
ViewBox handling[edit | edit source]
The ViewBox attribute of the SVG file defines the initial coordinate system for displaying its content. The OpenSCAD import supports the tranformations including the preserveAspectRatio attribute. The article Understanding SVG Coordinate Systems and Transformations gives a nice introduction of how all combinations of the viexBox related attributes affect the display.
DPI handling[edit | edit source]
Open and closed shapes[edit | edit source]
OpenSCAD handles only closed polygons, so importing lines or open polygons is not possible. Instead open polygons are treated as shapes defined by their stroke-width.
Closed shapes are always using the geometric specification regardless of fill or stroke-with defined in the SVG file.