X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f Date: Wed, 23 Mar 2016 16:56:56 -0400 Message-Id: <201603232056.u2NKuuGr023019@envy.delorie.com> From: DJ Delorie To: geda-user AT delorie DOT com In-reply-to: <1458766246.2911.85.camel@linetec> (geda-user@delorie.com) Subject: Re: [geda-user] PNG export question References: <1458766246 DOT 2911 DOT 85 DOT camel AT linetec> Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk The easiest way to do custom outputs like this is to post-process the *.pcb file to a new file, and print that (just grepping out all the line/arc/via entries, for example). For example, I have a pcb2paste script that extracts all the pads and edits them (attached). Otherwise, drawing pins and pads is handled differently for the GUI than for the exporters. #!/usr/bin/perl # -*- perl -*- $margin = 10000; while ($ARGV[0] =~ /^-/) { $opt = shift; $bothsides = 1 if $opt eq "-b"; if ($opt eq "-m") { $margin = shift; } } $in = shift; $out = shift; if (! $in) { print "pcb2paste [-b] [-m] in.pcb out.pcb\n"; print "-b\tboth sided\n"; print "\m\tmargin\n"; exit 0; } open (IN, $in); open (OUT, ">$out"); while () { if (/^PCB\["(.*)" (.*) (.*)\]/ && $bothsides) { ($name, $width, $height) = ($1, $2, $3); $width = $width * 2 + $margin; $_ = "PCB[\"$name\" $width $height]\n"; } if (/^Element/) { if (/^Element\["" "" "" "" \d+ \d+ 0 0 0 100 ""\]/) { $target = 1; } else { $target = 0; } ($ex, $ey) = m@ ([-0-9]+) ([-0-9]+) @; $save = $_; $keep = 0; while () { next if /Pin/; next if /Element(Arc|Line)/; next if /nopaste/; if (/Pad/) { $keep = 1; if ($target && /Pad\[-1250 -1250 -1250 -1250 2450 2000 3500 "" "1" "square"\]/) { $save .= "Pad[-2500 0 2500 0 100 100 100 \"\" \"1\" \"\"]\n"; $save .= "Pad[0 -2500 0 2500 100 100 100 \"\" \"1\" \"\"]\n"; if ($bothsides) { $x1 = $width - 2*$ex - 2500; $x2 = $width - 2*$ex + 2500; $save .= "Pad[$x1 0 $x2 0 100 100 100 \"\" \"1\" \"\"]\n"; $x1 = $width - 2*$ex; $save .= "Pad[$x1 -2500 $x1 2500 100 100 100 \"\" \"1\" \"\"]\n"; } $save .= ")\n"; $_ = scalar while ! /^\s*\)/; } else { ($prefix, $x1, $y1, $x2, $y2, $pwidth, $suffix) = /(\s*Pad.) *(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)/; if (0) { if ($pwidth > 7000) { $pwidth = int($pwidth * 0.8); } else { $pwidth = int($pwidth * 0.8); } } $save .= "$prefix$x1 $y1 $x2 $y2 $pwidth $suffix\n"; if (/Pad/ && $bothsides) { $x1 = $width - 2*$ex - $x1; $x2 = $width - 2*$ex - $x2; $save .= "$prefix$x1 $y1 $x2 $y2 $pwidth $suffix\n"; } } } else { $save .= $_; } last if /^\s+\)/; } print OUT $save if $keep; next; } if (/^Layer.*paste/) { print OUT; print OUT scalar ; while () { print OUT; last if /^\)/; } next; } next if /^\s*Text/; next if /^Via/; next if /^\s+Line/; next if /^\s+Arc/; next if /^\s+Arc/; if (/Polygon/) { while (($_=) !~ /\)/) { if (/Hole/) { while (($_=) !~ /\)/) { } } } next; } print OUT; } close IN; close OUT;