--- In kicad-users@yahoogroups.com, Robert <birmingham_spi...@...> wrote: > > Hmmm - that would be a lot of manual editing. OK, thanks. At least I > can now solve it with a bit of C code if they insist on this one.
Give this a try (I hope the Y! formatting doesn't totally destroy it.) May need to be tweaked for your house Gerber style. #!/usr/bin/perl # # Usage: perl shrink_paste.pl [input] [shrinkage] {minimum} # # Define $scale as the factor from the units of the command line shrinkage # value to the units in the Gerber. For a command line unit of mm and a # Gerber unit of inches, use 25.4. # If specified, the minimum dimension will be respected. If not specified, # it defaults to 0.0. Units are assumed to be the same as shrinkage and # similarly affected by the scale factor. $scale = 25.4; $minimum = 0.0; $iname = $ARGV[0]; if ($iname eq "") { print "No input filename\n"; exit; } $oname = $iname; $bakname = $iname; $base = rindex($oname, ".pho"); if ($base == -1) { print "Input not a Gerber? (Not .pho)\n"; exit; } $shrinkage = $ARGV[1]; if ($shrinkage == 0) { print "Quitting, no shrinkage spec'd\n"; exit; } $shrinkage /= $scale; $minimum = $ARGV[2]; if ($minimum < 0.0) { $minimum = 0.0; } $minimum /= $scale; substr($oname, $base) = ".tmp"; substr($bakname, $base) = ".bak"; open (IFILE, $iname) or die "$iname: $!"; open (OFILE, ">", $oname) or die "$oname: $!"; $working = 0; $x = 0.0; $y = 0.0; while (<IFILE>) { chomp; if (!$working) { printf(OFILE "%s\n", $_); if (/APERTURE LIST/) { $working = 1; } } elsif ($working) { if (/APERTURE END LIST/) { $working = 0; printf(OFILE "%s\n", $_); } else { @field = split(/[,X\*]/); if ($field[0] =~ /C/) { $x = $field[1] - $shrinkage; if ($x < $minimum) { $x = $minimum; } printf(OFILE "%s,%.6f*%\n", $field[0], $x); } elsif ($field[0] =~ /[RO]/) { $x = $field[1] - $shrinkage; if ($x < $minimum) { $x = $minimum; } $y = $field[2] - $shrinkage; if ($y < $minimum) { $y = $minimum; } printf(OFILE "%s,%.6fX%.6f*%\n", $field[0], $x, $y); } } } } close(IFILE); close(OFILE); rename($iname, $bakname); rename($oname, $iname);