11 June 2020

Converting an SVG file to DXF via the terminal requires Inkscape and pstoedit. There might be other ways too, but this was the easiest way. I also use SVGO to clean up the SVG beforehand, to possibly reduce complexity.

Source code viewer
  1. # Optimize the SVG file using SVGO (optional but can help reduce file size and complexity)
  2. svgo example.svg
  3.  
  4. # Convert the optimized SVG file to EPS format using Inkscape
  5. inkscape -o example.eps example.svg
  6.  
  7. # Convert the EPS file to DXF format using pstoedit
  8. # -dt : Disable text conversion (keeps text as text objects)
  9. # -f 'dxf:...' : Specify DXF output format with options:
  10. # - -polyaslines: Convert polygons to polylines (useful for CAD software)
  11. # - -mm : Use millimeters as the unit instead of points
  12. pstoedit -dt -f 'dxf:-polyaslines -mm' example.eps example.dxf
Programming Language: Bash