Skip to content

Instantly share code, notes, and snippets.

@vfsoraki
Created January 20, 2020 10:42
Show Gist options
  • Save vfsoraki/d261d0db963e0df9575d1201a247692a to your computer and use it in GitHub Desktop.
Save vfsoraki/d261d0db963e0df9575d1201a247692a to your computer and use it in GitHub Desktop.
Convert SVG to DXF in Linux using Inkscape and pstoedit
#! /bin/bash
# Install required applications
# Ubuntu:
# apt-get install inkscape pstoedit
# Arch:
# pacman -S inkscape pstoedit
function svgToEps()
{
if test $# -lt 1 ; then
echo "You need to pass in a filename." ; return
fi
epsfile="${1%.*}.eps"
echo "inkscape -f '$1' -E '$epsfile'"
inkscape -f "$1" -E "$epsfile" >/dev/null 2>&1
}
function svgToDxf()
{
if test $# -lt 1 ; then
echo "You need to pass in a filename." ; return
fi
base="${1%.*}"
epsfile="${base}.eps"
dxffile="${base}.dxf"
svgToEps "$1"
echo "pstoedit -psarg '-dNOSAFER' -dt -f 'dxf_14:-splineasbezier' '${epsfile}' '${dxffile}'"
# There are other versions of this command around the net, but for me, "-psarg '-dNOSAFER'" was required.
# Some kind of Ghostscript option.
pstoedit -psarg '-dNOSAFER' -dt -f 'dxf_14:-splineasbezier' "${epsfile}" "${dxffile}" >/dev/null 2>&1
rm "$epsfile"
}
# Run the function
svgToDxf "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment