Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

OpenSCAD User Manual/Importing Geometry/SVG Import

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

SVG Import 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); // Development snapshot Parameters file String. The name of the file to import. center Boolean. If set to true, the imported geometry is centered by bounding box of the geometry. dpi Double. Use this DPI ("dots per inch") 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). In this case, you can set the DPI to get the desired scaling. For example, if you want each unit in the SVG file to be 1 mm, then set dpi=25.4 (1 inch = 25.4 mm) to preserves the size of the SVG object in millimeters. If an absolute unit is given for width/height (px/pt/pc/in/mm/cm) in the SVG file, the DPI value is ignored. $fn Double. The number of polygon segments to use when converting circles, arcs, and curves to polygons. Development snapshot $fa Double. The minimum angle step to use when converting circles and arcs to polygons. Development snapshot $fs Double. The minimum segment length to use when converting circles and arcs to polygons. Development snapshot id String. The id of an element or group to import. Development snapshot layer String. The layer to import (Works with the way Inkscape labels its layers in the SVG files). Development snapshot Limitations 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 Coordinate system origin The $fn,$fa,$fs parameters can only increase resolution, not reduce it compared to the previously fixed resolution. ViewBox handling 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 viewBox related attributes affect the display. DPI handling Open and closed shapes 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 always use the geometric specification defined in their SVG, regardless of fill or stroke-width, except for closed polylines, which are treated as open polygons and defined by their stroke-width. center 200 Closed shapes ignore fill and stroke-width, open path use stroke width to generate the outline of the shape. OpenSCAD svg-import circles-and-arcs.svg SVG in Inkscape OpenSCAD svg-import circles-and-arcs (OpenSCAD).png Imported into OpenSCAD