Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert SVG files to DXF files on Mac OS X
#!/usr/bin/perl -w
# - convert SVG files to DXF files on Mac OS X
# by Patrick Pelletier, public domain (or cc0)
# based on the commands suggested here:
# assumes is installed in /Applications
# and pstoedit is installed in PATH, such as via "brew install pstoedit"
use Cwd qw(abs_path);
use File::Temp ();
die "Usage: $0 filename.svg\n" if ($#ARGV != 0); # 0 means 1 argument
my ($src) = @ARGV;
$src = abs_path($src); # because inkscape changes current directory
my $dest = $src;
$dest =~ s/\.svg$/.dxf/;
die "filename doesn't end in .svg" if ($src eq $dest);
my $intermediate = File::Temp->new(SUFFIX => '.eps');
system ("/Applications/", "-E",
$intermediate, $src) == 0 or die "inkscape failed";
system ("pstoedit", "-q", "-dt", "-f", "dxf:-polyaslines -mm",
$intermediate, $dest) == 0 or die "pstoedit failed";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.