Created
May 4, 2016 02:22
-
-
Save mignon-p/eba27c66b3a20d89ca4e1e30c05e81c1 to your computer and use it in GitHub Desktop.
Convert SVG files to DXF files on Mac OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# svg-to-dxf.pl - convert SVG files to DXF files on Mac OS X | |
# by Patrick Pelletier, public domain (or cc0) | |
# based on the commands suggested here: | |
# https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_2D_formats | |
# assumes Inkscape.app 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/Inkscape.app/Contents/Resources/bin/inkscape", "-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