X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=panel2pcb;fp=panel2pcb;h=b281dec2b4a85762882f2aef247b2a37ac991077;hp=0000000000000000000000000000000000000000;hb=1bf6c604ddb905d6f6898b1472ac94d085f4b223;hpb=6d789ebc45563080cc731487a3a3455a3d8d6ef2 diff --git a/panel2pcb b/panel2pcb new file mode 100755 index 0000000..b281dec --- /dev/null +++ b/panel2pcb @@ -0,0 +1,99 @@ +#!/usr/bin/perl +# -*- perl -*- + +# Copyright 2006 DJ Delorie +# Released under the terms of the GNU General Public License, version 2 + +if (! @ARGV) { + print "Usage: pcb2panel board1.pcb board2.pcb board3.pcb > boards.pcb"; + print "Then edit boards.pcb, putting each outline where you want it\n"; + print "and sizing the board. Then:\n"; + print "panel2pcb [-l regex] boards.pcb\n"; + print "and edit/print boards.panel.pcb\n"; + exit 0; +} + +$mydir = $0; +if ($mydir =~ m@/@) { + $mydir =~ s@[^/]*$@@; +} else { + $mydir = "."; +} + +require "$mydir/panel.pl"; + +$panel = shift; + +if ($panel eq "-l") { + $panelcopperlayers = shift; + $panel = shift; +} + +open(P, $panel); +while (

) { + if (/PCB\[.* (\S+) (\S+)\]/) { + $panel_width = &parseval($1); + $panel_height = &parseval($2); + } + if (/Element\[\"[^\"]*\" \"([^\"]*)\" \"([^\"]*)\" \"([^\"]*)\" (\S+) (\S+)/) { + $pcb = $1; + $base = $2; + $value = $3; + $mx = &parseval($4); + $my = &parseval($5); + %pinx = (); + %piny = (); + } + if (/Pin\[(\S+) (\S+) \S+ \S+ \S+ \S+ \"(\d)\"/) { + $pinx{$3} = &parseval($1); + $piny{$3} = &parseval($2); + } + if ($pcb && /\)/) { + if ($pinx{'1'} < $pinx{'2'}) { + $rot = 0; + } elsif ($pinx{'1'} > $pinx{'2'}) { + $rot = 2; + } elsif ($piny{'1'} < $piny{'2'}) { + $rot = 3; + } elsif ($piny{'1'} > $piny{'2'}) { + $rot = 1; + } + push (@paste, "$pcb\0$rot\0$mx\0$my"); + $pcb = undef; + } + if (/Via/) { + push (@panelvias, $_); + } + if (/^Layer\([^)]*\)$/) { + $junk =

; # The opening '(' + while ($junk =

) { + last if $junk =~ /^\)/; + push (@panelcopper, $junk); + } + } +} + +$tmp = "/tmp/panel$$.pcb"; + +$start = $paste[0]; +$start =~ s/\0.*//; + +$panel =~ s/\.pcb$//; +&baseboard($start, $panel_width, $panel_height, $panel); + +$lastboard = undef; +for $paste (sort @paste) { + ($pcb, $rot, $mx, $my) = split(/\0/, $paste); + if ($lastboard ne $pcb) { + &loadboard ($pcb); + $lastboard = $pcb; + $lastrot = 0; + } + while ($lastrot != $rot) { + print PS "PasteBuffer(Rotate,1)\n"; + $lastrot = ($lastrot+1) % 4; + } + print PS "PasteBuffer(ToLayout,$mx,$my)\n"; +} + +&done();