Skip to content

Instantly share code, notes, and snippets.

@javadoug
Forked from winder/svgToDxf.sh
Last active March 30, 2016 12:46
Show Gist options
  • Select an option

  • Save javadoug/1c5acc922e08eca8d910ef83b24b7de0 to your computer and use it in GitHub Desktop.

Select an option

Save javadoug/1c5acc922e08eca8d910ef83b24b7de0 to your computer and use it in GitHub Desktop.

Revisions

  1. Doug Ross revised this gist Mar 30, 2016. 2 changed files with 35 additions and 28 deletions.
    35 changes: 35 additions & 0 deletions svg2dxf.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Convert SVG to EPS
    # on mac run brew install pstoedit then
    # add these two functions to your .bashrc file
    # source .bashrc if terminal is already open
    # Usage:
    # > svg2dxf art.svg # outputs art.dxf
    #
    function svg2eps() {
    if test $# -lt 1 ; then
    echo "You need to pass in a filename." ; return
    fi

    wdir="`pwd`"
    epsfile="${wdir}/${1%.*}.eps"

    echo "inkscape -f $1 -E $epsfile"
    inkscape -f "${wdir}/$1" -E "$epsfile" &> /dev/null
    }

    function svg2dxf() {
    if test $# -lt 1 ; then
    echo "You need to pass in a filename." ; return
    fi

    wdir="`pwd`"
    base="${wdir}/${1%.*}"
    echo "base is ${base}"
    epsfile="${base}.eps"
    dxffile="${base}.dxf"

    svg2eps "$1"
    echo "pstoedit -dt -f 'dxf:-polyaslines -mm' ${epsfile} ${dxffile}"
    pstoedit -dt -f 'dxf:-polyaslines -mm' "${epsfile}" "${dxffile}" &> /dev/null
    rm "$epsfile"
    }
    28 changes: 0 additions & 28 deletions svgToDxf.sh
    Original file line number Diff line number Diff line change
    @@ -1,28 +0,0 @@
    # Convert SVG to EPS
    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
    }

    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 -dt -f 'dxf:-polyaslines -mm' ${epsfile} ${dxffile}"
    pstoedit -dt -f 'dxf:-polyaslines -mm' ${epsfile} ${dxffile} &> /dev/null
    rm $epsfile
    }
  2. @winder winder created this gist Feb 1, 2014.
    28 changes: 28 additions & 0 deletions svgToDxf.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    # Convert SVG to EPS
    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
    }

    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 -dt -f 'dxf:-polyaslines -mm' ${epsfile} ${dxffile}"
    pstoedit -dt -f 'dxf:-polyaslines -mm' ${epsfile} ${dxffile} &> /dev/null
    rm $epsfile
    }