0

I need to convert multiple SVG files to DXF for use with a laser cutter. I know how to do it with Inkscape using the GUI using File > Save As, but it is tedious if I have a lot of files to convert.

So I have found how to batch export using Inkscape command line :

$ inkscape --export-type="dxf" *.svg

The GUI lets you choose between DXF R12 or DXF R14 format, and the command above seems to use the DXF R12 format.

How to use the DXF R14 format with the command line?

1 Answer 1

1

I had the same question and downloaded the Inkscape source from https://gitlab.com/inkscape/inkscape in order to understand the internal mechanisms.

A full-text search for R12 and R14 revealed that these formats are exported using Inkscape extensions, dxf12_outlines and dxf_outlines, respectively (output shortened):

[~/source/inkscape]$ grep R12 po/de.po -C 1                                                                                                                                                                                                                                      
#: ../share/extensions/dxf12_outlines.inx:9
msgid "Desktop Cutting Plotter (AutoCAD DXF R12) (*.dxf)"
msgstr "Desktop-Schneideplotter (AutoCAD DXF R12) (*.dxf)"

[~/source/inkscape]$ grep R14 po/de.po -C 1
#: ../share/extensions/dxf_outlines.inx:49
msgid "Desktop Cutting Plotter (AutoCAD DXF R14) (*.dxf)"
msgstr "Desktop-Schneideplotter (AutoCAD DXF R14) (*.dxf)"

I then learned that the Inkscape extensions live in their separate repository at https://gitlab.com/inkscape/extensions. Looking at the source of dxf_outlines.py, the docstrings confirm that this script effectively outputs the R14 format: https://gitlab.com/inkscape/extensions/-/blob/master/dxf_outlines.py#L22

On my Ubuntu 20 system with Inkscape installed via snap, the script is executed as follows:

/usr/bin/python3 /snap/inkscape/current/share/inkscape/extensions/dxf_outlines.py --output=file.dxf file.svg

As a prerequisite, I had to install the lxml and numpy extensions for Python 3:

sudo apt install python3-lxml python3-numpy

Hope this helps!

1
  • Thanks for the investigation. On my Mac I found the script in /Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/dxf_outlines.py Oct 20, 2021 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.