PerfectVector
By Irene Kim9 min read

OpenSCAD SVG Import: Build a Measured, Extrudable Shape

Import SVG geometry into OpenSCAD, check holes and dimensions, then extrude a measured shape. Learn why a white center may need repair to become a real hole.

On this page

OpenSCAD SVG import starts with import("emblem.svg");. That loads a two-dimensional shape. To make a solid, wrap the import in linear_extrude(). Before adding height, check the outline, the empty spaces, and the intended width. A drawing that looks right in a browser can still contain a background rectangle or a white shape where you expected a hole.

This guide separates those checks using a traced flower emblem. The source, actual PerfectVector output, and explicitly edited SVG show what changed before the CAD step. The SVG geometry was inspected; the OpenSCAD examples below are instructions to run on your own file, not results from a tested OpenSCAD model.

Start with the shape you want to manufacture

Use the original vector file if you have it. Re-tracing a screenshot of an existing SVG adds work and can change its outline. If the only source is a PNG, JPG, or generated image, prepare an SVG for 3D printing with PerfectVector, then inspect the downloaded paths before importing them into CAD.

For a first extrusion, choose one bold silhouette with a generous opening. Leave small lettering, narrow bridges, detached dots, and decorative texture for a later version. The drawing's size on your screen does not establish whether those features will survive at the final part size.

Your working file should answer three questions:

  • Which regions should become solid material?
  • Which regions should stay empty through the part?
  • How wide should the finished outline be in millimeters?

The broader image-to-SVG workflow for 3D printing covers source selection. Here, the task is getting that outline into OpenSCAD with intentional geometry and dimensions.

A white center is not automatically a hole

We converted a prepared 1,254 × 1,254 raster flower through PerfectVector and inspected the unmodified SVG. It contained three closed paths: a near-white background rectangle, a black flower silhouette, and a near-white center circle. There were no embedded raster images.

The center looked empty on a white page, but it was a separate painted shape. Removing that circle alone would expose the solid black flower underneath. It would not cut a hole.

For a separate working SVG, we removed the verified background and put the original flower and circle contours into one compound path with an even-odd fill rule. The contour coordinates stayed unchanged. Rendering that edited SVG confirmed transparent pixels at the center and outside the flower, with an opaque black lobe between them. This checks the SVG's negative space; it does not prove a valid OpenSCAD solid or a printable part.

Raster flower, raw three-path SVG, and edited compound-path SVG with a transparent center shown against blue with blue SVG path outlines
Prepared raster source and actual PerfectVector output. The third panel is an edited working SVG: the background was removed and the original center contour made into a hole. These are SVG renders, not OpenSCAD renders. Blue lines overlay the actual SVG paths for inspection; background outlines are omitted.

OpenSCAD's importer uses the geometry of closed shapes rather than treating their painted appearance as the modeling instruction. Its documented support also has limits around text, clipping, and masking. For CAD preparation, turn the intended material into explicit paths and make intended holes actual cutouts. See the SVG import documentation.

In a vector editor, work on a copy: identify the outer silhouette and the inner shape, subtract the inner shape from the outer one, then save the result. Put a contrasting background behind it temporarily to check that the opening is transparent. Remove that temporary background before saving the CAD copy. If the silhouette has several openings, inspect each one.

Import the prepared SVG as 2D geometry

Save your CAD-ready file as emblem-cad.svg beside the OpenSCAD document. Start with just this:

import("emblem-cad.svg", center = true);

Preview the import and look at it from above. You should see the intended outline and the intended opening, without a rectangle around the artwork. center = true centers the imported bounding box; it does not repair paths or discard unwanted shapes. OpenSCAD's SVG import reference describes this parameter and its default behavior.

If the import is empty, confirm the filename and relative location first, then read the console messages. Open the SVG in a vector editor to check whether it contains real shapes rather than an embedded image. An .svg extension alone does not establish that the picture was traced.

If the center fills in, return to the working SVG. Changing its visible color to white is not the repair. If a rectangle appears, inspect the background geometry before trying another extrusion setting.

Set a deliberate width before adding height

SVGs carry dimensions through their document size, units, and coordinate system. OpenSCAD's dpi parameter applies when relevant dimensions lack explicit units or are missing; it is not a universal scale correction. Do not change DPI repeatedly until a shape happens to look plausible. The import manual explains when the parameter applies.

For an emblem whose overall width should be 40 mm, set that dimension explicitly:

resize([40, 0, 0], auto = true)
    import("emblem-cad.svg", center = true);

Here, resize() sets the X dimension to 40, while auto = true scales the unspecified dimensions proportionally. This differs from scale(), which multiplies the existing dimensions. The transformation reference documents both operations.

That width is only useful after removing unwanted background geometry: otherwise, you could be sizing the surrounding rectangle instead of the emblem. If you already need the file to preserve a known physical size across applications, fix its document units and verify them rather than routinely overriding every import. The guide to SVGs importing at the wrong size walks through that distinction.

Forty millimeters is an example dimension, not a recommended minimum. At your chosen size, check the narrowest bridge, the center opening, and any separate islands against the needs of your printer, material, and part.

Extrude, render, then inspect the exported model

Once the 2D outline and width look right, add a straight extrusion:

linear_extrude(height = 3)
    resize([40, 0, 0], auto = true)
        import("emblem-cad.svg", center = true);

Read this from the inside outward: import the prepared shape, set its width, then give it 3 mm of height. This is the basic SVG extrusion pattern in the 2D subsystem manual. The height is another example choice, not a structural recommendation.

Keep this first model simple. Extra twist, taper, unions, or surface placement can obscure whether the original import was correct. Check the top and side views: the hole should remain open through the extrusion, and the expected outline should have height.

Run a full render with F6, review any errors, then export the model as STL when that is the format your next application needs. The STL export guide distinguishes rendering from export. A successful preview is not the final acceptance check.

Open the exported file in your slicer. Verify its overall dimensions, the opening, and the layers through the part. Detached decorative pieces may be valid geometry yet unsuitable for the intended object. A clean SVG and a completed render cannot make that design decision for you.

Diagnose the failing stage

What you seeFirst thing to inspectUseful next action
A solid rectangleA traced background pathRemove the verified background in the working SVG.
The center fills inA white overlay instead of a true holeSubtract the center from the silhouette and recheck transparency.
The outline is the wrong sizeDocument dimensions, units, or unwanted boundsCheck the source units or set a deliberate proportional width.
A line disappears or changes thicknessOpen versus closed path geometryConvert the intended material into explicit filled shapes.
Preview looks acceptable but rendering failsConsole errors and suspect path intersectionsSimplify to the isolated import, then repair the source geometry.
The slicer loses small detailsFeature size at the final scaleEnlarge or simplify the design and inspect the layers again.

The SVG extrusion troubleshooting guide goes deeper into broken contours and other geometry repairs. Keep a raw SVG alongside your working copy so you can tell which changes came from the conversion and which you made for CAD.

FAQ

Can OpenSCAD import an SVG directly? Yes. Use import("emblem.svg"); to load its supported 2D geometry. Check the paths and dimensions before wrapping the import in linear_extrude() to create a 3D shape.

Why does my SVG's hole become solid in OpenSCAD? The apparent hole may be a white filled object sitting on a solid silhouette. Prepare a real cutout in a working SVG and inspect it against a contrasting background before reimporting.

How do I control the size of an imported SVG? Check its document dimensions and units first. To set a chosen overall width, apply resize([40, 0, 0], auto = true) before extrusion, replacing 40 with your intended width. Remove unwanted background geometry before sizing the bounds.

Does converting an image to SVG make it ready to print? No. Conversion provides paths to inspect and prepare. You still need suitable closed geometry, intentional holes and dimensions, a valid extrusion, and a slicer check for your particular design and process.

Sources

  1. OpenSCAD SVG import reference — Supported geometry, import parameters, units, and limitations.
  2. OpenSCAD transformations — Proportional resizing, scaling, and transformation order.
  3. OpenSCAD 2D subsystem — Linear extrusion of imported SVG geometry.
  4. OpenSCAD STL export — Full rendering and the export step.

If your emblem still exists only as pixels, convert the raster artwork into SVG paths, then check one silhouette and one opening before building the OpenSCAD model. Keep the original vector when it already gives you the shapes you need.

More from the blog

Start from an image to create SVG paths for 3D printing