Renumbering reference designators

Is there a way to automatically re-number reference designators, and then import that back into the schematic?

I see some simular questions, but no answers.

References are the only key values in the .net and .cmp files, this means you cannot propagate reference changes without breaking the board layout and module assignments. There is no way to tell that the newly renamed C3 was the C12 before the renaming…

The operation could’ve been possible if there were another unique identifier keeping its value even when reference changes, but that’s not the case, Kicad’s data model isn’t built this way.

In case I’ve misunderstood and your question was just about re-annotating the schematics, it is done in the annotation dialog (in the upper toolbar, the button with opamp symbol and U?A 123 text).
Checking “reset existing annotation” will rename all the refs, but as I’ve said in the previous message, this will break your downstream cmp assignment and board layout.

I know how to renumber the schematic and get those into the layout, but I haven’t seen the reverse procedure.

For the record, here’s how to renumber a schematic and update the layout (mostly doing this to record it in my own notes):

  1. Make sure the schematic and layout are in sync. They probably are anyway, but if not, create the .net and .cmp files in eeschema and import them into pcbnew. This insures the component timestamps in the schematic and layout are the same.
  2. Now change the references in your schematic.
  3. Create a new .net file for the changed schematic, but don’t make a new .cmp file.
  4. In pcbnew, pull up the netlist import dialog and select “Timestamp” in the “Footprint Selection” section. (The default is “Reference”.) This makes pcbnew use the unique timestamps to associate schematic parts with PCB footprints instead of the references (which were changed). Then import the netlist.
  5. After importing the netlist, the references should change to reflect the schematic. Now use the File=>Fabrication Outputs=>Component (.cmp) File command to create a new .cmp file that records the new references and their associated footprints.

It seems the basic mechanisms are there to allow changing references in the PCB and back-annotating them to the schematic. I don’t know why it’s not available. Maybe not enough people have asked for it to make it worth the development time.

4 Likes

Hi,

Looking at the .cmp file format, the only identifying feature per component is the reference, so it appears KiCad is using this as the key when it does the Back-annotate. The TimeStamp value presumably tells it which is the newer reference.

BeginCmp
TimeStamp = /54C34CB1;
Reference = C1;
ValeurCmp = 0.1uF;
IdModule = Discret:C1;
EndCmp

in the netlist file

(comp (ref C1)
  (value 0.1uF)
  (footprint Discret:C1)
  (libsource (lib device) (part C))
  (sheetpath (names /) (tstamps /))
  (tstamp 54C34CB1))

and in the schematic

$Comp
L C C1
U 1 1 54C34CB1
P 3525 2375
F 0 “C1” H 3575 2475 50 0000 L CNN
F 1 “0.1uF” H 3575 2275 50 0000 L CNN
F 2 “Discret:C1” H 3563 2225 30 0001 C CNN
F 3 “” H 3525 2375 60 0000 C CNN
1 3525 2375
0 1 1 0
$EndComp

In the python documentation all attributes appear to be tied to the reference value also, so I first presumed changing it in pcbnew would break those links. To test this, I went into pcbnew in the above project, and edited the reference C1 to be FROG, then exported a .cmp file.

The new content became

BeginCmp
TimeStamp = 54ED54E9
Path = /54C34CB1
Reference = FROG;
ValeurCmp = 0.1uF;
IdModule = Discret:C1;
EndCmp

Where you can see the time stamp has changed, as well as the reference. There’s now a new value ‘Path’ holding the old timestamp though. Back in Eeschema I did a back-annotate to see what would happen. Capacitor reference FROG did not import and C1 remained changed.

Next test I went into pcbnew and swapped the references of C1 & C2 (both same footprint). This did not change their references (and therefore locations) in the schematic. Next test I went into pcbnew, and swapped references C1 & C7 (one a ceramic, the other an electrolytic). Same result.

New .cmp file record

BeginCmp
TimeStamp = 54ED54E9
Path = /54C34CB1
Reference = C7;
ValeurCmp = 0.1uF;
IdModule = Discret:C1;
EndCmp

So it appears from this the mechanism does exist for back-annotation to change the reference as the timestamp of the Eeschema footprint is recorded in the attribute ‘Path’. Perhaps there’s another reason it’s not implemented currently, but the design seems to allow for it.

Cheers!
Geoff

Edit: I should add all tests here run in KiCad build 2015-02-06 BZR5410 - YMMV depending on version

This is interesting idea, I’ve never tried this before (seems kind of counter intuitive). Will do the next time I renumber something…

I know this is an old topic but I think others will be interested. I had been looking for a renumber feature for some time and just but I just found a great utility to do this at https://documenteddesigns.com/kicad-pcb-renumbering-utility/ Go to the bottom of the page to see the links for the latest vesrion.

I used it to renumber seven different designs both flat and hierarchical without a problem :slight_smile:

It is command line based and saves the options after a run so it’s very easy to re-run if need be. I found the author most helpful.

3 Likes

Hey thanks for the referral to my program!

I am working on learning about GUIs so I can make a proper GUI version but it’ll take a while.

2 Likes