I was thinking of using awk (tawk) for this.
It can be done in a few lines (5 to 10 maybe) of awk code.
Awk is included on unix/linux and available for windows.
Just another idea but any solution that works is good enough.
Martin


On Fri, Apr 3, 2009 at 11:07 AM , Robert wrote:

> Oh wow!   Did you do this specially?   If so I'm really touched - 
> thank you.   I'll take a look at this today.   Being a C(++) 
> programmer I was thinking about doing this in C, but though I've not 
> written any Perl myself I reckon I should be able to edit this if I 
> need to and post it back.
>
> I guess the advantage of doing it in C is that it could be added to 
> the postprocess menu of kicad.   Anyone got any thoughts on that?   I 
> can write the code if it's thought worthwhile.
>
> Regards,
>
> Robert.
>
> axtz4 wrote:
>> --- In [email protected], 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);
>>
>>
>>
>>
>> ------------------------------------
>>
>> Please read the Kicad FAQ in the group files section before posting 
>> your question.
>> Please post your bug reports here. They will be picked up by the 
>> creator of Kicad.
>> Please visit http://www.kicadlib.org for details of how to contribute 
>> your symbols/modules to the kicad library.
>> For building Kicad from source and other development questions visit 
>> the kicad-devel group at 
>> http://groups.yahoo.com/group/kicad-develYahoo! Groups Links
>>
>>
>>
>>
>> 
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.283 / Virus Database: 
>> 270.11.39/2038 - Release Date: 04/02/09 19:07:00
>>

Reply via email to