1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-02 02:02:48 +02:00
eda-tools/genex/sym2xps
2012-03-30 20:02:24 -03:00

76 lines
1.2 KiB
Bash
Executable File

#!/bin/sh -e
#
# sym2xps - Convert a symbol from a Kicad library to Postscript with expanded
# pin types
#
# Copyright 2012 by 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.
#
usage()
{
echo "usage: $0 library symbol tmpdir outfile" 1>&2
exit 1
}
lib=$1
sym=$2
tmp=$3
out=$4
[ "$lib" ] && [ "$sym" ] && [ "$tmp" ] && [ "$out" ] || usage
[ -r "$lib" ] || {
echo "$lib: not found" 1>&2
exit 1
}
grep "^DEF $sym " "$lib" >/dev/null || {
echo "\"$sym\" not found in $lib" 1>&2
exit 1
}
[ "${tmp#/}" = "$tmp" ] && tmp=`pwd`/$tmp
[ "${out#/}" = "$out" ] && out=`pwd`/$out
mkdir "$tmp"
trap "rm -rf '$tmp'" 0
expand-pintype "$lib" "$tmp"/tmp.lib
cat <<EOF >"$tmp"/tmp.pro
[eeschema]
version=1
[eeschema/libraries]
LibName1=./tmp
EOF
X=6000
Y=4000
cat <<EOF >"$tmp"/tmp.sch
EESchema Schematic File Version 2 date Mon Mar 26 09:29:33 2012
LIBS:dummy
EELAYER 43 0
EELAYER END
\$Comp
L X$sym ??
U 1 1 00000000
P $X $Y
1 $X $Y
1 0 0 -1
\$EndComp
\$EndSCHEMATC
EOF
cd "$tmp"
eeschema --plot=ps "$tmp/tmp.sch"
mv tmp.ps "$out"