www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2013/11/07/16:02:20

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=NxKqz8dPb73iMyxbe2NxqQSVgQgEQncWWP40CT+ji1k=;
b=YQtLPsyps10GcO96tq+efI+TQZABvONY2epzQ/tRQBC3Gyw/hBPCNT8FKWKogbzvr+
HbJ2pQyL8SCjd6cDAiZeYXKYkmR6cW67OOhgUmUF1QN8nSrNEhtBvqbDvbiipdXHQ1ZI
GgjUz++NCL4cIY/ybTbdajkKHGT0Dk5R9gr6v64JG7F3vN18DbgQq/LhXNNmTGvwWj7k
3pdRcJBYa4MC650A8yseklPiq0sECqo9YnJRKMC7NPvIiyKXC5+pVyazA4oMhoKJbmAA
nhshal4kMyU9EFQXHZTfWSW4wc1+E5aOpMNi+nIVI+kzmYEhtpkEmerAzP3gyZMzODhP
i5OA==
X-Received: by 10.112.130.105 with SMTP id od9mr72153lbb.45.1383858060768;
Thu, 07 Nov 2013 13:01:00 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <CAGojTMExP001M3CG5Xd8LtpA8aq+VzMGmBixU_Z9Cjqccmc-dg@mail.gmail.com>
References: <CAGojTMExP001M3CG5Xd8LtpA8aq+VzMGmBixU_Z9Cjqccmc-dg AT mail DOT gmail DOT com>
From: Martin Held <diver DOT martin AT gmail DOT com>
Date: Thu, 7 Nov 2013 13:00:40 -0800
Message-ID: <CAGojTMFGemXHt+nWeFJGWG10q0J5E252jx-24V5kccjFim_Agw@mail.gmail.com>
Subject: [geda-user] Re: Perl hack for bulk updates of refdes'
To: geda-user <geda-user AT delorie DOT com>
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

--e89a8f64733d21c86d04ea9c9051
Content-Type: multipart/alternative; boundary=e89a8f64733d21c86904ea9c904f

--e89a8f64733d21c86904ea9c904f
Content-Type: text/plain; charset=ISO-8859-1

Oh, I didn't attach the actual file, derp.


On Thu, Nov 7, 2013 at 12:43 PM, Martin Held <diver DOT martin AT gmail DOT com> wrote:

> DJ suggested I send this hack to the mailing list directly.  This is an
> ugly perl hack, but then again, most perl hacks are.  I used it again today
> and remembered I forgot to mail this one in.
>
> I'm not a normal geda-user subscriber, so your best bet is to reply
> directly to me.
>
> I've found myself doing some big designs recently, wherein I add lots of
> components, redo stuff, do a layout, make some schematic changes, split off
> schematic files, split off board, recombine boards, make more changes, more
> pcb changes, etc etc.  In the end, the reference designators get all sorts
> of out-of-whack.  C200 near R1, stupid little OCD annoying stuff like that.
>
> The problem is that if you re-annotate your schematic (refdes, current
> page, overwrite all existing) when you have a PCB layout that's complete,
> there's no current 'good' way to forward annotate those changes without
> gnetlist (in my system) deleting half the components, only to make you add
> them all back in again, redo the refdes locations, yadda yadda.
>
> So here's a perl script to do what I needed.  Do this where you have a
> schematic and a corresponding layout.  You can probably break things by
> adding/removing components during this process.
>
> The first step is to grep refdes file.sch > pre.txt.  This creates a file
> of all reference designators.
> Then go into gschem with your schematic, and attributes -> autonumber text
> (or shortcut 'tu'), and wipe out all your reference designators with new
> ones.  Save and exit (backing up along the way might be a good idea too.. I
> commit to SVN each time before/after I do this).  You can also do any
> manual changes, e.g. if you don't like the top to bottom, diagonal/etc
> options in the autonumber menu.
>
> Then grep refdes file.sch > post.txt
>
> Now run the perl script.  It'll create a hash out of pre and post.txt, and
> then scan through the pcb file and change the reference designators as
> necessary.  Naturally, if you add or remove components, you can change the
> order of pre/post.txt... that will screw things up in the hash table.
>
> ./update.pl pre.txt post.txt file.pcb output.pcb
>
> You may also wish to re-run gnetlist, and then when you open the
> output.pcb file, reload the new netlist and ensure you didn't get any
> munged connectivity.
>
> If all goes well, you have reference designators that make more sense.
>
> License:  None, I don't care if you sell it or something, I use it for
> myself, it works for my needs.  You can even take credit for all I care.
>
> Cheers,
> Martin
> AE7IK
>
>
> -------------------------------------------------------------------------------
> If there aren't any questions, then what is there to learn?
>



-- 
Martin Held - PADI MSDT-190219
diver DOT martin AT gmail DOT com
http://www.raindroppro.com
-------------------------------------------------------------------------------
If there aren't any questions, then what is there to learn?

--e89a8f64733d21c86904ea9c904f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh, I didn&#39;t attach the actual file, derp.<br></div><d=
iv class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Thu, Nov 7, =
2013 at 12:43 PM, Martin Held <span dir=3D"ltr">&lt;<a href=3D"mailto:diver=
.martin AT gmail DOT com" target=3D"_blank">diver DOT martin AT gmail DOT com</a>&gt;</span> =
wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>DJ suggested I send th=
is hack to the mailing list directly.=A0 This=20
is an ugly perl hack, but then again, most perl hacks are.=A0 I used it=20
again today and remembered I forgot to mail this one in.<br><br></div>I&#39=
;m not a normal geda-user subscriber, so your best bet is to reply directly=
 to me.<br><div>
<br>I&#39;ve found myself doing some big designs recently, wherein I add=20
lots of components, redo stuff, do a layout, make some schematic=20
changes, split off schematic files, split off board, recombine boards,=20
make more changes, more pcb changes, etc etc.=A0 In the end, the reference
 designators get all sorts of out-of-whack.=A0 C200 near R1, stupid little
 OCD annoying stuff like that.<br>
<div><br>The problem is that if you re-annotate your schematic=20
(refdes, current page, overwrite all existing) when you have a PCB=20
layout that&#39;s complete, there&#39;s no current &#39;good&#39; way to fo=
rward=20
annotate those changes without gnetlist (in my system) deleting half the
 components, only to make you add them all back in again, redo the=20
refdes locations, yadda yadda.<br>
<br>So here&#39;s a perl script to do what I needed.=A0 Do this where you h=
ave
 a schematic and a corresponding layout.=A0 You can probably break things=
=20
by adding/removing components during this process.<br><br></div><div>The fi=
rst step is to grep refdes file.sch &gt; pre.txt.=A0 This creates a file of=
 all reference designators.<br>
</div><div>Then go into gschem with your schematic, and=20
attributes -&gt; autonumber text (or shortcut &#39;tu&#39;), and wipe out a=
ll=20
your reference designators with new ones.=A0 Save and exit (backing up=20
along the way might be a good idea too.. I commit to SVN each time=20
before/after I do this).=A0 You can also do any manual changes, e.g. if=20
you don&#39;t like the top to bottom, diagonal/etc options in the autonumbe=
r
 menu.<br>
<br></div><div>Then grep refdes file.sch &gt; post.txt<br><br></div><div>No=
w
 run the perl script.=A0 It&#39;ll create a hash out of pre and post.txt, a=
nd=20
then scan through the pcb file and change the reference designators as=20
necessary.=A0 Naturally, if you add or remove components, you can change=20
the order of pre/post.txt... that will screw things up in the hash=20
table.<br>
<br></div><div>./<a href=3D"http://update.pl" target=3D"_blank">update.pl</=
a> pre.txt post.txt file.pcb output.pcb<br><br></div><div>You
 may also wish to re-run gnetlist, and then when you open the output.pcb
 file, reload the new netlist and ensure you didn&#39;t get any munged=20
connectivity.<br>
<br>If all goes well, you have reference designators that make more sense.<=
br><br></div><div>License:=A0
 None, I don&#39;t care if you sell it or something, I use it for myself, i=
t
 works for my needs.=A0 You can even take credit for all I care.<br>
<br></div><div>Cheers,<br></div><div>Martin<br></div><div>AE7IK<br></div><b=
r>-------------------------------------------------------------------------=
------<br>If there aren&#39;t any questions, then what is there to learn?
</div></div>
</blockquote></div><br><br clear=3D"all"><br>-- <br>Martin Held - PADI MSDT=
-190219<br><a href=3D"mailto:diver DOT martin AT gmail DOT com" target=3D"_blank">dive=
r DOT martin AT gmail DOT com</a><br><a href=3D"http://www.raindroppro.com" target=3D"=
_blank">http://www.raindroppro.com</a><br>

---------------------------------------------------------------------------=
----<br>If there aren&#39;t any questions, then what is there to learn?
</div>

--e89a8f64733d21c86904ea9c904f--
--e89a8f64733d21c86d04ea9c9051
Content-Type: application/x-perl; name="update.pl"
Content-Disposition: attachment; filename="update.pl"
Content-Trans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PCRkb3JpZz4pIHsKICBteSAkY2hnbGluZSA9IDwkZG5l
dz47CgogIAogIG15IEBvcmlnZmllbGRzID0gc3BsaXQgIj0iICwgJG9yaWdsaW5lOwogIG15IEBj
aGdmaWVsZHMgPSBzcGxpdCAiPSIgLCAkY2hnbGluZTsKIAogIGNob21wICRvcmlnZmllbGRzWzFd
OwogIGNob21wICRjaGdmaWVsZHNbMV07CiAgJGNoYW5nZXN7JG9yaWdmaWVsZHNbMV19ID0gJGNo
Z2ZpZWxkc1sxXTsKICAKICAKfQoKY2xvc2UgKCRkb3JpZyk7CmNsb3NlICgkZG5ldyk7CgojTm93
IHByb2Nlc3MgdGhlIFBDQiBmaWxlCgp3aGlsZSAobXkgJGxpbmUgPSA8JGRtb2Q+KSB7CgogIGlm
KCRsaW5lID1+IC9FbGVtZW50XFsvICkKICB7CiAgICBteSBAbCA9IHNwbGl0ICIgIiAsICRsaW5l
OwogICAgcHJpbnQgRCAiJGxbMF0gJGxbMV0iOwogICAgCiAgICAkbFsyXSA9fiBzL1snXCInXS8v
ZzsKICAgIHByaW50IEQgIiBcIiRjaGFuZ2VzeyRsWzJdfVwiICI7ICAgIAogICAgcHJpbnQgRCAi
JGxbM10gJGxbNF0gJGxbNV0gJGxbNl0gJGxbN10gJGxbOF0gJGxbOV0gJGxbMTBdXG4iOwogICAg
aWYoJGxbMTFdKSAKICAgIHsKICAgICAgcHJpbnQgRCAiRVJST1IiOwogICAgfQogICAgCiAgfQog
IGVsc2UKICB7CiAgICBwcmludCBEICRsaW5lOwogIH0KICAKfQoKY2xvc2UgKEQpOwpjbG9zZSAo
JGRtb2QpOwoKICAK
--e89a8f64733d21c86d04ea9c9051--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019