OpenSCAD User Manual/Other 2D formats

Currently, OpenSCAD supports DXF only as a graphics format for 2D graphics. Other common formats are PS/EPS, SVG and AI.

PS/EPS
The pstoedit program can convert between various vector graphics formats. OpenSCAD needs the  option passed to the dxf output plugin to understand the file. The  option sets one mm to be one unit in the dxf; include this if you use one unit in OpenSCAD as equal to one millimeter. The  options instructs pstoedit to render texts, which is usually what you want if you include text. (If the rendered text's resolution in terms of polygon count is too low, the easiest solution is to scale up the eps before converting; if you know a more elegant solution, please add it to the example.)

pstoedit -dt -f "dxf: -polyaslines -mm" infile.eps outfile.dxf

SVG
Inkscape can convert SVG to EPS. Then pstoedit can convert the EPS to DXF.

inkscape -E intermediate.eps infile.svg pstoedit -dt -f dxf:-polyaslines\ -mm intermediate.eps outfile.dxf

Makefile automation
The conversion can be automated using the make system; put the following lines in your : The first line specifies which dxf files are to be generated when  is called in the current directory. The second paragraph specifies how to convert a file ending in .svg to a file ending in .eps, and the third from .eps to .dxf.

A more complete makefile could autogenerate dxf files from the any svg in the folder. In which case, put the following lines into your :

It's still possible to call  to build a particular file, but this code also allows for (re)building of all dxf files in a folder just by calling   or.

This code is also universal enough that it's possible to put the code in a single file and symlink every makefile in any directory that has svg files for dxf conversion by running: in each respective directory.

AI (Adobe Illustrator)
Although Adobe Illustrator CC/CC.2014 allows you to export illustrations as DXF (and select DXF format versions as early as 12), it uses DXF entities that are not supported by OpenSCAD, such as  and.

Since pstoedit does not natively support Adobe Illustrator files, one alternative is to use EXDXF, which is an Adobe Illustrator plug-in (30 free trial exports and then you have to pay $90 to register the plugin).

Before exporting, it is recommended that you ensure that your Artboard is the same dimensions as the component you are exporting. Although EXDXF provides you with numerous options when exporting to DXF the most important option for OpenSCAD compliance is to set  to.

OpenSCAD doesn't always provide information about the issues it encountered with a DXF import. If this happens, select  and then.

Previous
../DXF Extrusion/

Next
../Short and Commented Example Projects/