OpenSCAD User Manual/Other 2D formats

From Wikibooks, open books for an open world
Jump to: navigation, search


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

PS/EPS[edit]

The pstoedit program can convert between various vector graphics formats. OpenSCAD needs the -polyaslines option passed to the dxf output plugin to understand the file. The -dt 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 scape up the eps before converting; if you know a more elegant solution, please add it to the example.)

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

SVG[edit]

pstoedit does not understand SVG, but EPS can be converted from an SVG. inkscape, an SVG editor, can be used for conversion.

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

Makefile automation[edit]

The conversion can be automated using the make system; put the following lines in your Makefile:

 all: my_first_file.dxf my_second_file.dxf another_file.dxf
 
 %.eps: %.svg
 	inkscape -E $@ $<
 
 %.dxf: %.eps
 	pstoedit -dt -f dxf:-polyaslines\ -mm $< $@

The first line specifies which dxf files are to be generated when make 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.