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:from:date:message-id:subject:to:content-type; bh=HS1JKZcVsJ77Pev9zSPtW/xThT+CMPVJGHdy/9ktXRg=; b=eWYfRDVNV4wJILp9YycglxkVF3Hxdga2JdJr32Hq8aLdcFoWAiIex1LlHvKOcHjYdU h4WSoJ7HMd/fzOnrLZOc6yyL6VGjRu4w+TL3uqgHA/d02AF0ptBVycJYDqpO1cEp43Va SilUxn6YvaO0TPCYt8lY5b/t1bvLUYPPUbg54LiMZZoyE8aNZp7WqE0ewYOx8WwN/Cof RRvxNyNequP9FKzTijX5ZXkKqmOxVhkN5FYJwPLTCBkARyg0WU3QDVLPgTJTZl+YOpiZ km0v+Z+0J+RNiNyq6nKxo8iH3iywvT6QpHRPY2bXJiOx46UTcxCKBR+3jHBj8bNLtZ3N UcBQ== X-Received: by 10.112.144.105 with SMTP id sl9mr1293672lbb.37.1383857021091; Thu, 07 Nov 2013 12:43:41 -0800 (PST) MIME-Version: 1.0 From: Martin Held Date: Thu, 7 Nov 2013 12:43:21 -0800 Message-ID: Subject: [geda-user] Perl hack for bulk updates of refdes' To: geda-user Content-Type: multipart/alternative; boundary=047d7b3a82f429842804ea9c5237 Reply-To: geda-user AT delorie DOT com --047d7b3a82f429842804ea9c5237 Content-Type: text/plain; charset=ISO-8859-1 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? --047d7b3a82f429842804ea9c5237 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
DJ suggested I send this hack to the mailing list dir= ectly.=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.

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=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.

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's complete, there's no current 'good' 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.

So here'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.

The fi= rst step is to grep refdes file.sch > pre.txt.=A0 This creates a file of= all reference designators.
Then go into gschem with your schematic, and=20 attributes -> autonumber text (or shortcut 'tu'), 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't like the top to bottom, diagonal/etc options in the autonumbe= r menu.

Then grep refdes file.sch > post.txt

No= w run the perl script.=A0 It'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.

-------------------------------------------------------------------------= ------
If there aren't any questions, then what is there to learn?
--047d7b3a82f429842804ea9c5237--