refdes_renum: warn of possible number clash with non-conforming values
[geda-gaf/whiteaudio.git] / gnetlist / scripts / sch2eaglepos.sh
blob5f098a7fc61b79d0383a753997ed5dcb7c97ec2f
1 #!/bin/sh
2 # By Braddock Gaskill (braddock@braddock.com), August 2004. This
3 # software is hereby declared to be in the public domain by Braddock
4 # Gaskill, the author.
5 FNAME="$1"
6 if [ -z "$FNAME" ]; then
7 cat << EOF
9 $0 <inputfile.sch>
11 This script will read a gschem schematic and attempt to
12 extract the relative positions of the components in the schematic,
13 and generate corresponding MOVE instructions for Eagle. You will
14 likely have to adjust XOFFSET, YOFFSET, XSCAL, and YSCALE at the
15 top of the script to obtain usable positions.
17 By Braddock Gaskill (braddock@braddock.com), August 2004
19 EOF
20 exit -1
22 XOFFSET=40000
23 YOFFSET=33000
24 #XSCALE=10000
25 #YSCALE=10000
26 XSCALE=9000
27 YSCALE=9000
29 tmpdir=/tmp/$$
30 mkdir -m 0700 -p $tmpdir
31 rc=$?
32 if test $rc -ne 0 ; then
33 cat << EOF
35 $0: ERROR -- Failed to create $tmpdir with 0700 permissions. mkdir returned $rc.
37 Make sure that $tmpdir does not already exist and that you have permissions to
38 create it.
40 EOF
41 exit 1
43 tmpf=${tmpdir}/tmpf
44 grep -B1 refdes= "$FNAME" |sed 's/=/ /' | cut -d" " -f2,3 |grep -v '^--' >${tmpf}
47 while read; do
48 # the directory on the client to backup
49 X=`echo $REPLY | cut -d' ' -f1`
50 Y=`echo $REPLY | cut -d' ' -f2`
51 read;
52 PART="$REPLY"
53 X=`echo "scale=5; ($X - $XOFFSET) / $XSCALE" |bc`
54 Y=`echo "scale=5; ($Y - $YOFFSET) / $YSCALE" |bc`
55 echo "MOVE '$PART' ($X $Y);"
56 done < $tmpf
57 rm -fr "${tmpdir}"