Root/
| Source at commit 09d27e5b668df4b122b9da21762924bbb26d3772 created 6 years 7 months ago. By Werner Almesberger, genkicat/sym2xps: generate EPS, not PDF (closer to the original Postscript) | |
|---|---|
| 1 | #!/bin/sh -e |
| 2 | # |
| 3 | # sym2xps - Convert a symbol from a Kicad library to Postscript with expanded |
| 4 | # pin types |
| 5 | # |
| 6 | # Copyright 2012 by Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | |
| 15 | usage() |
| 16 | { |
| 17 | echo "usage: $0 library symbol unit tmpdir outfile" 1>&2 |
| 18 | exit 1 |
| 19 | } |
| 20 | |
| 21 | |
| 22 | lib=$1 |
| 23 | sym=$2 |
| 24 | unit=$3 |
| 25 | tmp=$4 |
| 26 | out=$5 |
| 27 | |
| 28 | [ "$lib" ] && [ "$sym" ] && [ "$unit" ] && [ "$tmp" ] && [ "$out" ] || usage |
| 29 | |
| 30 | [ -r "$lib" ] || { |
| 31 | echo "$lib: not found" 1>&2 |
| 32 | exit 1 |
| 33 | } |
| 34 | |
| 35 | grep "^DEF $sym " "$lib" >/dev/null || grep "^DEF ~$sym " "$lib" >/dev/null || { |
| 36 | echo "\"$sym\" not found in $lib" 1>&2 |
| 37 | exit 1 |
| 38 | } |
| 39 | |
| 40 | [ "${tmp#/}" = "$tmp" ] && tmp=`pwd`/$tmp |
| 41 | [ "${out#/}" = "$out" ] && out=`pwd`/$out |
| 42 | |
| 43 | mkdir "$tmp" |
| 44 | |
| 45 | trap "rm -rf '$tmp'" 0 |
| 46 | |
| 47 | expand-pintype "$lib" "$tmp"/tmp.lib |
| 48 | |
| 49 | cat <<EOF >"$tmp"/tmp.pro |
| 50 | [eeschema] |
| 51 | version=1 |
| 52 | [eeschema/libraries] |
| 53 | LibName1=./tmp |
| 54 | EOF |
| 55 | |
| 56 | X=6000 |
| 57 | Y=4000 |
| 58 | |
| 59 | # |
| 60 | # @@@ Known bug: doesn't handle spaces in component names (F1) well. |
| 61 | # Example: usb_a_plug.lib had F1 "USB_A_PLUG " 0 ... |
| 62 | # |
| 63 | |
| 64 | sed "\@^DEF $sym @,/^ENDDEF/p;d" "$lib" | |
| 65 | awk '/^F. / { if ($1 == "F0") sub(/"$/, "?\"", $2); |
| 66 | print substr($1, 1, 1), substr($1, 2, 1), $2, |
| 67 | $6, '$X'+$3, '$Y'+$4, $5, " 0000", $8, $9 }' >"$tmp"/fx.tmp |
| 68 | #F field_number "text" orientation posX posY size Flags (see below) |
| 69 | #F0 reference posx posy text_size text_orient visibile htext_justify vtext_justify |
| 70 | |
| 71 | cat <<EOF >"$tmp"/tmp.sch |
| 72 | EESchema Schematic File Version 2 date Mon Mar 26 09:29:33 2012 |
| 73 | LIBS:dummy |
| 74 | EELAYER 43 0 |
| 75 | EELAYER END |
| 76 | \$Descr A4 0 0 |
| 77 | \$EndDescr |
| 78 | \$Comp |
| 79 | L X$sym ?? |
| 80 | U $unit 1 00000000 |
| 81 | P $X $Y |
| 82 | `cat "$tmp"/fx.tmp` |
| 83 | $unit $X $Y |
| 84 | 1 0 0 -1 |
| 85 | \$EndComp |
| 86 | \$EndSCHEMATC |
| 87 | EOF |
| 88 | |
| 89 | cd "$tmp" |
| 90 | #eeschema --plot=ps "$tmp/tmp.sch" |
| 91 | eeplot -o "$tmp/tmp.eps" "$tmp/tmp.pro" |
| 92 | mv "$tmp/tmp.eps" "$out" |
| 93 | |
Branches:
master
