Inkscape to OpenSCAD converter
by dnewman, published
Liked ByView All
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
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,
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.
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.
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.
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").
From the "Extensions" menu, select "Generate from Path > Paths to OpenSCAD".
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.
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.
- 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.
Upgrade this Thing with Thingiverse AppsCustomization
Edit, personalize, or revise this ThingPrint Fulfilment
Order a print of this ThingTools and Utilities
Repair, slice, or enhance this Thing
Inkscape to OpenSCAD converter by dnewman is licensed under the GNU - GPL license.
What does this mean?
- Remixing or Changing this Thing is allowed.
- Commercial use is allowed.
Show Some Love
Say thanks by giving dnewman a tip and help them continue to share amazing Things with the Thingiverse community.Tip Designer
We're sure dnewman would love to see what you've printed. Please document your print and share a Make with the community.
To post a Make simply visit this Thing again and click I Made One to start uploading your photo. It’s even easier to post a Make via the Thingiverse Mobile app (available via Google Play and Apple App Store).