1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-28 13:42:24 +02:00
eda-tools/fab/pos2fab
Werner Almesberger 47b53c8ef3 fpdoc: new utility to generate a PDF with the footprints used in a project
- fab/pos2fab: can be called with "do", to read .pos and .cmp file
- fpd2pdf/fpd2pdf: added syntax extension file.fpd:package to allow
  selection of a single package
- fpd2pdf/fpdoc: generate a PDF with the footprints used in a specific
  project
2011-03-23 04:34:06 -03:00

67 lines
1.2 KiB
Perl
Executable File

#!/usr/bin/perl
#
# pos2fab - Condition a KiCAD .pos file for SMT fab use
#
# Written 2011 by Werner Almesberger
# Copyright 2011 Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
sub usage
{
print STDERR "usage: $0 pos-file cmp-file\n";
exit(1);
}
if (!defined caller) {
&usage unless @ARGV == 2;
$pos = $ARGV[0];
$cmp = $ARGV[1];
}
open(FILE, $pos) || die "$pos: $!";
while (<FILE>) {
chop;
next if /^#/;
my @f = split(/\s+/);
$pos{$f[0]} = [ $f[2], -$f[3]+0, $f[4] ];
push(@order, $f[0]);
}
close FILE;
open(FILE, $cmp) || die "$cmp: $!";
while (<FILE>) {
chop;
if (/^BeginCmp/) {
undef $ref;
undef $mod;
next;
}
if (/^Reference\s*=\s*(\S+)\s*;/) {
$ref = $1;
next;
}
if (/^IdModule\s*=\s*(\S+)\s*;/) {
$mod = $1;
next;
}
next unless /^EndCmp/;
$fp{$ref} = $mod;
}
close FILE;
return 1 if defined caller;
print "\"Ref\",\"Footprint\",\"PosX(in)\",\"PosY(in)\",\"Rot(ccw)\"\n" || die;
for (@order) {
print "\"$_\",\"$fp{$_}\",$pos{$_}[0],$pos{$_}[1],$pos{$_}[2]\n" ||
die;
}