[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: Action to flip board
Install this plugin:
http://www.delorie.com/pcb/boardflip.c
And use this script (boardflip):
#!/bin/sh
# -*- sh -*-
FILE=$1
OUTFILE=$2
if [ x"$OUTFILE" = x"" ]
then
OUTFILE=$FILE
mv $FILE $FILE.preflip
FILE=$FILE.preflip
fi
pcb --action-string "BoardFlip(sides) SaveTo(LayoutAs,$OUTFILE) Quit()" $FILE
Like this:
PCB = \
mypcb1.pcb \
mypcb2.pcb
PCF = $(PCB:.pcb=.pcf)
all : $(PCF) grouped.pnl grouped.pcb
@true
grouped.pnl :
pcb2panel $(PCB) $(PCF) > grouped.pnl
exit 1
grouped.pcb : grouped.pnl $(PCB) $(PCF)
panel2pcb grouped.pnl # from gedasymbols
drillhelper grouped.pcb # optional
%.pcf : %.pcb
boardflip $< $@.tmp
./swaplayers < $@.tmp > $@
rm $@.tmp
This is ./swaplayers (boardflip doesn't quite get this right):
#!/usr/bin/perl
# -*- perl -*-
while (<>) {
print;
if (/Groups\("(.*)"\)/) {
print STDERR "Groups: <$1>\n";
@groups = split(':', $1);
for $g (@groups) {
print STDERR "Group: <$g>\n";
@layers = split(',', $g);
for $l (@layers) {
print STDERR "Layer: <$l>\n";
if ($l eq "s") {
$solder = &max(@layers);
}
if ($l eq "c") {
$component = &min(@layers);
}
}
}
last;
}
}
print STDERR "C: $component S: $solder\n";
while (<>) {
if (/^Layer\((\d+)(.*)/) {
$l = $1;
$j = $2;
if ($l >= $component && $l <= $solder) {
$n = ($solder+$component) - $l;
print STDERR "L: $l -> $n\n";
s/Layer\(\d+/Layer\($n/;
}
}
if (/thermal\(([^\)]*)\)/) {
@t = ();
$old = $1;
for $t (split (',', $old)) {
$t =~ s/(\d+)/($component+$solder-2)-$1/ge;
push (@t, $t);
}
$t = join(',', sort @t);
s/thermal\([^\)]*\)/thermal($t)/;
}
print;
}
exit 0;
sub max {
my (@m) = @_;
my ($v, $vv) = $m[0];
for $vv (@m) {
$v = $vv if $vv =~ /\d/ && $v < $vv;
}
print STDERR "max ", join(', ', @m), " = ", $v;
return $v;
}
sub min {
my (@m) = @_;
my ($v, $vv) = $m[0];
for $vv (@m) {
$v = $vv if $vv =~ /\d/ && $v > $vv;
}
print STDERR "min ", join(', ', @m), " = ", $v;
return $v;
}
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user