Inkscape to OpenSCAD converter

by dnewman, published

Inkscape to OpenSCAD converter by dnewman Jun 13, 2012
0 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps



Inkscape to OpenSCAD converter by dnewman is licensed under the GNU - GPL license.

Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

20700Views 9702Downloads Found in Art Tools


UPDATED - paths2openscad-3.zip
UPDATED - paths2openscad-2.zip
See Thing 25036 for version 2 and 3

This Thing is an Inkscape extension to export Inkscape paths to OpenSCAD. There has been at least one prior Thing attempting this, Thing #9376. However, it only handled a small subset of SVG. This extension handles SVG arcs, clones, circles, ellipses, groups, lines, paths, polygons, polylines, rects, and splines. It also follows document transforms as well as viewports. Either an entire document or just the selected portions of a document are processed.

SVG text must first be converted to a path within Inkscape using Inkscape's "Path > Object to Path" menu item.

Note that another approach to importing SVG into OpenSCAD is to save the SVG to DXF from within Inkscape. Then use OpenSCAD's import() function to import the DXF. [Older versions of OpenSCAD used import_dxf().]

Much of the core code in this extension is derived from work done by myself and others while developing the Inkscape driver for the Eggbot.

9 May 2013: Modified the code to remove non alphanumeric characters from the names of the generated OpenSCAD modules.

15 June 2012: Added support for a single level of polygon nesting. I.e., subtract from a polygon, the polygons contained within it AND from the same Inkscape path. This works well for most fonts. You can tell Inkscape to combine multiple polygons into a single path by selecting the polygons and then using "Path > Combine". (You do not need to do this for text converted to a path: Inkscape already does the proper combining.)

15 June 2012: Corrected Windows issue with handling of Unix-style file paths.



Download the paths2openscad-2.zip file from this page. After unzipping that archive, you should have two files: paths2openscad.py and paths2openscad.inx .

The paths2openscad.zip file is the original release of the extension. It has been superseded by paths2openscad-2.zip.


Once you have downloaded paths2openscad.zip, open the zip file and place its contents in your local Inkscape extension folder,


on Linux and OS X. On Windows systems, you can place them directly into the Inkscape extension directory. For example, if Inkscape is installed in C:/Program Files/Inkscape then the extension directory will be C:/Program Files/Inkscape/share/extensions.

Once you have placed the two files in the proper directory, exit and then restart Inkscape. The extension should appear under the "Extensions > Generate from Path" menu as "Paths to OpenSCAD".


To use the extension,

  1. You may find it helpful to set your document units to millimeters and the document dimension to millimeters as well as a reasonable document size (e.g., 100 x 100 mm). Do this with the "File > Document Properties" menu item. The document units is in the upper part of the dialog box while the document dimensions are near the bottom of that same box.

  2. To see what the extension sees, set Inkscape's display mode to "outline". This is done with the "Display Mode" item of the "View" menu.

  3. Next ensure that within Inkscape, the desired objects have been converted to paths. Use the "Path > Object to Path" menu item to convert objects such as text to paths.

  4. Select the desired objects to generate an OpenSCAD program for. If you wish to generate a program for the entire document, then select nothing (i.e., "Edit > Deselect").

  5. From the "Extensions" menu, select "Generate from Path > Paths to OpenSCAD".

  6. In the dialog window which appears, enter the name of the output file to generate. (Windows users: the "~" notation indicates that the file goes into your "Document and Settings" folder.) You can also enter a extrusion height and a smoothing parameter. For most purposes, a smoothing parameter of 0.2 is sufficient. If your paths have lots of tight, twisty curves which are described using arcs, circles, ellipses, or other SVG elements which aren't collections of straight line segments, then you may want to use a smaller value.

  7. Click the "Apply" button. A pop-up window will appear while the extension is running and will then disappear when it is done running. After the extension is done running, you can click the "Close" button to dismiss the extension's dialog window. If an error occurs, you will see an error window appear when the extension is running.

  8. From OpenSCAD, open the output file you generated with the extension and render it.


If you wish to build solids involving subtracting one polygon from another, be sure to combine the two polygons into a single path: select the polygons and then combine them with "Path > Combine". Only a single level of nesting is handled at present. You do not need to do this for text converted to a path: Inkscape already does the proper combining.

I have seen a few complex, but legitimate polygons, compile and render with F5 but not with F6 in OpenSCAD. They instead trigger some internal error detection code in OpenSCAD.


The sample .svg, .stl, and .scad files serve as examples: you do not need to download them to use this Inkscape extension. You only need the .zip file.

More from Art Tools

view more

All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

Great tool... Should be part of official Inkscape release.

"From OpenSCAD, open the output file you generated with the extension and render it."

sorry i am new, but after i open up openscad, i could not found the output file. where is it by default?

The file is placed in your login directory if that is where you saved it from Inkscape. (That's the default location unless you changed the location.)

If you still cannot find it, then use the "search for files" function in your operating system to locate the file you saved in Inkscape. Save it in Inkscape but note the name of the file. Then search for it.

sorry dnewman, i do not know what did i do.
what does this statement means

"Traceback (most recent call last):
File "paths2openscad.py", line 909, in
File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 268, in affect
File "paths2openscad.py", line 866, in effect
self.recursivelyTraverseSvg( [self.selected[id]], transform )
File "paths2openscad.py", line 778, in recursivelyTraverseSvg
if not self.warnings.has_key( 'image' ):
AttributeError: OpenSCAD instance has no attribute 'warnings'

You tried to convert an SVG file containing an image. That's not supported. Remove the image. Or convert the image to a path first, but you must remove the image.

hey, thanks dnewman. it works like a charm !!!

This "Thing" would be great if I were not so stupid but I can't get the "Paths to OpenScad" up.

Yes, I got the SVG file I wanted from the JPEG. First I could not find the "Generate from Path" which I finally found in the "Extensions" but then I could not find the "Path to OpenScad". I did the "object to path." I followed the instruction to close down Inkspace and reopen. Nothing changed. I figured out that I had to select the object (image) again. Still I can't find Paths to OpenScad." I found "paths to g-code" but no "paths to OpenScad." It's confusing enough calling an image a "path."

Seriously, I need help.

Sounds like you are having difficulty installing extensions for Inkscape. You may want to inquire in the Inkscape user groups. Pretty much everything I know about installing Inkscape extensions is written in the Instructions section here.

This is wonderful and it works BUT I want to create token which includes 2 images converted,i copied both codes into scad and put a disk in-between them scad fails and crashes but do them singularly and they are fine. Any reason why it is doing this?

Run the latest OpenSCAD. Then, if you have code which crashes OpenSCAD then I'm sure the OpenSCAD folks would be curious to learn about it. Most software developers welcome bug reports since one of the ways to improve their software is to have users report bugs. And crashing generally indicates a bug of some sort.

Ahh fixed it, I thought I had the latest version but turned out I didnt. No Problem after all. Cheers

Fantastically useful program!!!

I do encounter names like:
module poly_path7776-1-8-7-3-9-8-4-9-8(h)

which my copy of OpenSCAD chokes on. I solve this by taking the .scad file into Notepad++ and doing a regex replace:

       Find What: ([0-9])(-)([0-9])
Replace With: \1\3

I have to run it twice, but it removes the dashes and OpenSCAD seems happy with the results.

Thanks again!

Interesting. Was the SVG originated in Inkscape or imported to Inkscape? Either way, I'll look into dealing with this in the extension -- pretty simple to handle and I should have the first time round. However, I'm curious if this signifies that Inkscape has changed its path naming conventions or if it's just a side effect of SVG from another application.


both imported into InkScape and originated there. InkScape verions 0.48 if that is relevant.

I've updated with a v3. Only change is to run the id through a very simple regex substitution which just strips all non-alphanumerics.

Very clever, thank you for sharing! Works fine, though it didn't want to export to "~" on my windows machine for some reason, so I used "D:" instead. Having it export to the same folder and with the same name as the source file by default, would save time locating and moving files around.

The polygon issue with not rendering "o"'s is a downside though. Is there any way to detect this, and export the holes as a csg difference() or something? One could do it manually, but then dxf would seem like the faster option anyway.

This needs to be submitted to the Inkscape codebase, so we ca
n have .scad export as default!

Updated to handle rendering of font characters such as "o", "8", etc. Also fixed the issue with handling Unix style file names on Windows.

You can pull the new paths2openscad-2.zip file for the update.

For things like the letter "o", a simple solution may well be to track the bounding box of each polygon. Then, when one polygon is entirely contained within another one, assume that a difference() is called for. The code needs to be a little smarter than that so that it can handle deeper nestings (e.g., a bunch of concentric circles). Should be fairly easy to implement and test. Once I'm done, I'll put a revised version of the extension up here.

Hmmm... Must be a windows or python version thing as the ~ works on my XP SP3 system (and I'm using the Python routine intended to deal with the issue in a cross platform fashion). I don't know if I can detect the directory containing the original document or not: the extensions are a separate process running python which is then fed over a pipe (or via a temp file) the current version of the SVG document. It may be that Inkscape puts the document name
amp; path into the document. If so, then I can grab it and use it. Note that the extension's dialog box itself cannot do any extension specific processing. The dialog is described via a static XML document which Inkscape loads when it starts running and then the main Inkscape process builds the dialog from that XML description. No system whereby code running with/for the dialog can be specified. Thus, it's not possible to within the dialog to present a document specific file name. Would have to be a check box along the lines of "save the file with a .scad extension in the same folder as the source document".

It is possible to detect the topology of the objects. For instance, intersect lines with them and count the crossings. (Indeed, I wrote the hatch and cross hatch extensions which get used with Inkscape.)

As to submitting to Inkscape, I'm fine with someone doing that. However, I'm not myself in
terested in maintaining it for Inkscape as that involves using Bazaar and I'm not interested in using that particular source control system in my free time. (The Inkscape folks have asked for me to contribute a couple of extensions: I've always told them that they can have 'em but then they want me
to maintain them in Bazaar.)

My DXF export plugin (http://www.thingiverse.com/thing:14221)http://www.thingiverse.com/thi... automatically convert objects (such as text) to paths for you. You are welcome to pull that code into this project if you like.

Inkscape OpenSCAD DXF Export

Interesting. I'll give that a look-see. It would definitely be useful for the Eggbot as well. I'll get in touch with you privately after I've had a time to look at it in a few weeks. Thanks much for pointing this out.