#/usr/contrib/bin/perl use Getopt::Std; getopts('s:f:rmh'); $scale = 1; $format = "a4"; $rotate = 0; if(defined $opt_h){ print "\nUsage: gerber2ps [ -s Scale ] [ -f Format ] [ -r ] [ -m ] infile [ outfile ]\n\n"; print "DESCRIPTION:\n"; print "gerber2ps converts Gerber 274X (.art) files to\n"; print "Postscript (.ps) format.\n"; print "gerber2ps is only tested with Cadence, Cadstar, and Protel Artwork files !!!\n\n"; print "-s defines the scale factor It's limited to the paper's extents\n"; print "-f defines the paper format (A0-A4) Default is A4\n"; print "-r rotates the plot by 90 deg\n\n"; print "-m creates a mirrored picture\n\n"; exit 1; } if(defined $opt_s){ # print "-s $opt_s\n"; $scale = $opt_s; } if(defined $opt_f){ # print "-f $opt_f\n"; $format = $opt_f; } if(defined $opt_r){ # print "-r \n"; $rotate = 1; } $mirror = 0; if(defined $opt_m){ # print "-s $opt_m\n"; $mirror = 1; } $format =~ s|a|A|; # Say Hello: print "This is Andy's Gerber274x to PS Utility, Ver. 0.01\n"; # Open Input- and Output-Files unless ($#ARGV > -1) # Identify arguments { print "Error: No Input File specified!\n"; exit 1; } $infile = $ARGV[0]; # Try to open Input unless(open(IN,"<".$infile)){ print "Input-File $infile is empty, I will try $infile".".art!\n"; $infile = $infile.".art"; # forgotten .eps ending ? unless(open(IN,"<".$infile)){ print "Error: Input-File $infile is empty, too!\n"; exit 1; } } if($#ARGV > 0){$outfile = $ARGV[1];} else{ if($outfile=~ m|([\w\.]*)\.art$|){ $outfile = $1.".ps"; } else { $outfile = $infile.".ps"; } } unless(open(OUT,">".$outfile)){ print "Error: Cannot open Output-File!\n"; exit 1; } if($mirror ==0){ $log=`gerber2eps $infile`; } else { $log=`gerber2eps -m $infile`; } print "$log\n=====\n\n"; $infile2=$infile.".epsf"; #print "infile2= $infile2 outfile = $outfile\n"; if ($rotate==0) { $log=`eps2ps -s$scale -f$format $infile2 $outfile`; } else { $log=`eps2ps -s$scale -f$format -r $infile2 $outfile`; } print "$log\n=====\n\n"; unlink $infile2; close(IN);