Inkscape to OpenSCAD converter v6

by dnewman, published

Inkscape to OpenSCAD converter v6 by dnewman Jun 15, 2012


___UPDATE: added version 6 of Thing #24808___
___This is version 6 of Thing #24808___
___At github as github.com/l0b0/paths2openscad .___

Libre Graphics World has a nice write up by Alexandre Prokoudine of this extension at libregraphicsworld.org/blog/entry/inkscape-gets-openscad-converter

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.

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

___21 June 2012:___ Correct a typo in the extension. Would not affect content generated by Inkscape but might have affected SVG content generated elsewhere and loaded into Inkscape.

___9 May 2013:___ Modified the code to remove non alphanumeric characters from the strings used to generate the OpenSCAD module names. Some SVG paths had non alphanumeric characters in their path ids and those ids were being used to generate OpenSCAD module names. OpenSCAD doesn't allow that.

___29 May 2013:___ Corrected an issue whereby the converted could exit with an error when attempting to warn about images embedded in the SVG file or Inkscape drawing. Images are not allowed and the converter cannot convert them. However, it should gracefully warn about the issue and exit normally.

___30 May 2013:___ Fixed a bug in the v4 version.

___16 Aug 2013:___ Possible workaround to Inkscape bug experienced by some users, "terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid"

Recent Comments

view all

Whatever software you used to create the SVG must have decided to use 72 units / inch. It should have, using standardized SVG, specified that it was using units of printer's points, pt, which are 72 pt to 1 inch. Looks as though it didn't, or there's a bug in the openscad converter which isn't handling the unit specification correctly.

I'll look into the SVG. Do you have thoughts on why I would end up with 72 units / inch being the correct scale instead of 90?

You need to fix your SVG to have units or correct units. SVG files should specify the units used (cm, ft, in, m, mm, pc, or pt) and if no units are specified then user units are assumed as per the SVG specification. Moreover 1 user unit is defined to be 1px. Further, the conversion from px to mm is 90px to 25.4 mm. (More precisely, 90px is defined to be 1inch.) So, if things are scaled improperly, the issue is likely with your SVG and you need to correct the usage of units in your SVG file.

P.S. Technically, if no units are specified then the measurement defaults to "user" units. But 1px is defined to be 1 user unit so you can use them interchangeably.

More from Tools

view more


Liked By

view all


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

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



MAC 10.7 or later users, see the second note in the Notes section! This means Lion, Mt. Lion, and beyond.

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


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,

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

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

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

3. 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").

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

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

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

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


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

2. OS X Lion (10.7) and Mt. Lion (10.8) users need a "patch" to allow Inkscape extensions to work correctly. This is a general Inkscape issue and not specific to this extension. At issue is the lack of a Python package, lxml, which Inkscape extensions use to read (parse) SVG files. Install the patch from code.google.com/p/eggbotcode/downloads/detail?name=EggBot2.2.2.r2.mpkg.zip . This will also give you Eggbot extensions, many of which I wrote. (An Eggbot is a cool pen plotter for plotting on Eggs.)


You must be logged in to post a comment.

Chinasaur on Mar 2, 2014 said:

Hi, I've had a scaling issue with the plugin; maybe you can spot where I went wrong from my description or maybe it's a bug. See here: http://www.thingiverse.com/thi...

Basically, the resulting SCAD seems to be almost exactly 80% of the proper scaling. The SCAD source includes scale factors of 25.4/90, so apparently the coordinates exported from Inkscape are expected to have 90 units to the inch? This would seemingly need to be 72 units / inch to give me the right size SCAD forms. What do you think?

dnewman on Mar 2, 2014 said:

You need to fix your SVG to have units or correct units. SVG files should specify the units used (cm, ft, in, m, mm, pc, or pt) and if no units are specified then user units are assumed as per the SVG specification. Moreover 1 user unit is defined to be 1px. Further, the conversion from px to mm is 90px to 25.4 mm. (More precisely, 90px is defined to be 1inch.) So, if things are scaled improperly, the issue is likely with your SVG and you need to correct the usage of units in your SVG file.

P.S. Technically, if no units are specified then the measurement defaults to "user" units. But 1px is defined to be 1 user unit so you can use them interchangeably.

darxx1 on Feb 25, 2014 said:

Hola, si yo lo convierto en vector primero, lo hago como dice el video tutorial de you tobe,de como pasar jpg a stl y no lo encuentro despues nose donde lo archiva.. saludos y gracias por responder

darxx1 on Feb 25, 2014 said:

Hola, instale Inkscape y cargue la extension de Paths to OpenSCAD, pero cuando hago todo el procedimiento para pasar JPG a STL, no se donde va el archivo, no lo encuentro alguin me puede ayudar??

dnewman on Feb 25, 2014 said:

The converter only operates on SVG vector elements. It does not operate on images embedded in SVG. You need to convert the images to vector graphics first. Inkscape does have a bitmap trace function which might be able to do that, but it also leaves the bitmap in the file and you have to then remove the embedded bitmap.

Loesch on Dec 7, 2013 said:

Running OSX 10.8.5 but when I select the Paths to OpenSCAD extension, I see a quick popup window that it's working, but no file is created. Seached entire drive with Finder JIC it was put somewhere else. Any ideas?

dnewman on Dec 8, 2013 said:

Works fine for me on OS X 10.7 and 10.9. When you run the extension, there's a popup window entitled "Paths to OpenSCAD". In that window, you select an output file name. (Default is a file in your login directory and with the extension .scad.) The conversion isn't done until you click the pop-up window's "Apply" button. If you're not getting the initial pop-up window, then something is wrong with your Inkscape or Python installation. If you get that window but no output file when you click the Apply button, then you may have a permissions problem.

Chinasaur on Oct 20, 2013 said:

Is there a summary somewhere of how this approach compares to the Export DXF method?

dnewman on Oct 20, 2013 said:

No. But the obvious difference is that this approach puts out a format from which a 3D model in STL, OFF, DXF, or CSG can be saved: open the .scad file in OpenSCAD, render it, and then write as a 3D model. If you produce DXF from Inkscape, then you only have a 2D rendering in DXF. You may then be able to extrude that in SolidWorks or similar.

Oldmicah on Sep 8, 2013 said:

Hey. Just wanted to say that you are my hero. I've been trying to model/print out a project for about a year now without much luck. I read about your script and thought, what the heck. It took a little while, but I'm in the middle of printing it (successfully) now.

Of course, now that the 'simple project' worked, I'm trying a more complex version. (SCad's been running for about 2 hours now and I'm ~10% done:)

Seriously, thank you for putting this out there. And thanks from my 3d animation friends b/c I'll stop bugging them!

cjbissonnette on Aug 17, 2013 said:

When I run this I get:

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid

Inkscape 0.48, version 5 of your tool.

dnewman on Aug 17, 2013 said:

That's an Inkscape bug which depends upon what platform you are using. I myself do not see it on OS X 10.7.5 nor on Windows 7 with Inkscape 0.48. Consequently, I cannot diagnose it. However, stwice a while back did some spelunking and determined that on his/her computer a cosmetic change in the .inx file resolved the issue. I've uploaded a v6 that implements that change at the expense of not presenting quite as nice of a pop up window. (The .inx file describes to Inkscape what the window should look like. Inkscape creates the window, not the extension. And, it seems, that Inkscape still has some bugs in this department -- extension dialogs.)

Anonymous on Jul 23, 2013 said:

Is there a public repository for this? I'd love to keep up to date with the code rather than the "thing", and maybe clone to help out.

dnewman on Aug 17, 2013 said:

No public repo. Feel free to make one yourself and post back.

charlespax on May 30, 2013 said:

I got the below message when I open Inkscape, opened one of the samples, and started the extension.

charles@charles-lenovot420:~$ inkscape
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.
Aborted (core dumped)


dnewman on Aug 18, 2013 said:

Charles, another user tracked this down to a known (via google) issue with Inkscape and .inx file. v6 appears to remedy this on Ubuntu 12.04 at least. (I never had any luck reproducing it myself on OS X nor Windows.)

dnewman on May 30, 2013 said:


1. I found an error in a fix I uploaded last night. So, in a few minutes there will be a fix to the fix.

2. As to Inkscape itself aborting, that suggests a bug in Inkscape. The extension is merely a Python script which Inkscape launches. It reads some data from Inkscape, does its work, writes its own output file (which Inkscape doesn't know or care about), and then exits. It passes no information back to Inkscape. If Inkscape is then crashing, that suggests a bug in Inkscape, possibly associated with running extensions but outside the control of the extension. (If this is a Mac with Lion, there's a known bug in Inkscape 0.48.x with extensions. However, your prompt of "lenovot420" suggests otherwise.)

Thanks for the report,

brandonh on May 29, 2013 said:

Using Mac 10.6.8 + inkscape 0.48.2, I get this error when using the extension:

Traceback (most recent call last):

File "paths2openscad.py", line 912, in <module>


File "/Applications/Inkscape.app/Contents/Resources/extensions/inkex.py", line 215, in affect


File "paths2openscad.py", line 869, in effect

self.recursivelyTraverseSvg( [self.selected[id]], transform )

File "paths2openscad.py", line 781, in recursivelyTraverseSvg

if not self.warnings.has_key( 'image' ):

AttributeError: OpenSCAD instance has no attribute 'warnings'</module>

dnewman on May 30, 2013 said:

Thanks for posting that. I'll fix it. However, realize that the underlying problem is that you tried to process an Inkscape drawing with an image in it. The converter was intentionally aborting the operation. It then encountered an error as it was trying to tell you why it was aborting the operation. Had it successfully told you what the problem was, it still would have aborted. It just would have done so gracefully.

So, even when I fix this you still will be unable to process that Inkscape drawing or SVG file. You have to remove the image from it. Either that, or put the image in another layer and deactivate that layer. Or only select the part of the drawing you want converted, omitting the image.

sgparry on May 20, 2013 said:

I am using inkscape 0.48 on Ubuntu 13.04; I have downloaded v3 of the perl script and inx file and placed it in ~/.config/inkscape/extensions. Every time I run the script I get an internal error. Running from the shell shows the following additional information. All other scripts work fine. Can you advise please?

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid

dnewman on May 20, 2013 said:

That's an error from Inkscape and C++. The extension itself is Python code. If it was a problem with the extension code, you'd see a Python error and not a C++ error. Your issue is with Inkscape proper and you need to bring it up on an Inkscape forum. It may be that the extension is not properly installed (e.g., permissions) or some other problem. But this is not the extension itself. The extension doesn't even provide output which Inkscape reads back. Which is to say, it's not even possible for the extension to be providing incorrect output back to Inkscape.

Also, Ubuntu 13.04 is very new. It's not even clear if Inkscape 0.48 works correctly on Ubuntu 13.04. Another reason to brink this up in an Inkscape forum.

Anonymous on Mar 10, 2013 said:

I can't use it, when I try on osx 10.7.5 running python 2.7.1, it fails and tells me to install the 'fantastic lxml wrapper'. And that, is effectively impossible for me. I googled for 20 minutes trying to figure it out and it's a no go. Has anybody here gotten this working using the above mentioned versions? Thanks.

dnewman on Mar 10, 2013 said:

Runs fine on OS X 10.7.5 for me with Inkscape 0.48. The version of Python which Inkscape runs is often/typically not the version you see from the command line. As to the missing lxml, that is a generic Inkscape installation issue. You would be best to post to the Inkscape users group.

ErroneousBosch on Jan 20, 2013 said:

Nice plugin, but I keep having inkscape crash on me when I am trying to use it on a particular SVG. Any Advice?

dnewman on Jan 20, 2013 said:

That's a bug in Inkscape then. Extensions do not run within Inkscape. Inkscape writes the SVG to a temporary file and then Inkscape launches a separate process -- concurrently runs another program as though that program is another user. That separate process runs Python and executes the extension which reads in the SVG and then writes it back out again. Inkscape waits for that separate process to finish and then reads back in the SVG output by the separate process. If Inkscape is then dying, then Inkscape has a bug of some sort. While it's possible that the extension is putting out SVG which isn't what Inkscape wants to see (and may even be bad SVG), Inkscape should not crash. Instead it should report an error message.

So, you may want to make sure that you are running a recent version of Inkscape. OTOH, this may be a new bug in Inkscape. Also, it could be that the extension is putting out incomplete SVG, but I'd have to see the input file fed to the extension by Inkscape to tell. (It's some intermediate form of the SVG file you loaded into Inkscape.) Armed with that input and if there's a problem in the extension, then I could fix that. However, the bug in Inkscape would still remain -- the bug that makes it crash when it sees extension output it doesn't like.

Karabas on Jan 16, 2013 said:

can it convert arc or circle to arc, not to poligon?

dnewman on Jan 16, 2013 said:

No. Largely in part because Inkscape itself tends to use cubics for much of what it does anyway.

CodeAndReload on Jan 10, 2013 said:

I just want to note for Mac users to remove the leading tilde and slash and to check in Inkscape.app/Contents/Resources/extensions for your files.

For some reason because Inkscape is using X11, it save the file in the actual .app bundle. If I save it to "~/filename.scad", I haven't been able to find it, whereas "filename.scad" appears in the the bundle.

dnewman on Jan 11, 2013 said:

Thanks for posting this tip!

Alternatively, replace ~ with /Users/your-account-name/ to put it in your login directory or /Users/your-account-name/Desktop to put it on your Desktop.

At issue will be what does the HOME environment variable translate to in the process which Inkscape forks to run Python and the extension script. This can conceivably change with the X11 implementation (there are several for OS X), the Inkscape version (many), and maybe even your account's .profile file or other (hidden) login scripts. Hard to say. I'm a Mac user and I don't see this behavior on OS X 10.7.5 (Lion). But clearly YMWV (your mileage will vary).

VeimoX on Dec 29, 2012 said:


Nudel_P on Jun 16, 2012 said:

The nesting works perfectly, great job! This converter will definitively be part of my tool chain from now on. Thank you very much!

dnewman on Jun 16, 2012 said:

Thanks for the feedback. It is helpful!

I may add support for arbitrary depth within a path. Handling nesting between paths and clipping within a path and between paths may be overkill AND would definitely introduce dependencies on add'l Python libraries as well as some C/C++ shared libraries. Fortunately, an Inkscape user can simply
rearrange their paths to deal with those issues: it doesn't have to be dealt with in the converter.

And I need to plant to look at Polymaker's path converter for possible inclusion.