Tip: Schematic: move/cut/paste things to a different place without ruining the PCB (Kicad5)

This is a technique/workaround that i’ve often had to explain on IRC, so i’ll write it up here.

Intention: you wanna cut/paste (basically move) a bunch of things in the schematic from one place to another.

The problem: You have a project that already has complete or partial PCB Layout. If you use the cut/paste function in EEschema (at least in Kicad up to version 5.1.7) this action breaks your layout.

Why? Because when updating the changes to the board (F8), PCBNew uses one of two ways to figure out which Component in the schematic maps to which Footprint in the board:

  1. Associate by Reference - you know the annotated R1, R2, R3 on resistors, etc…
  2. Associate by Timestamp

Which one should you use? That depends on what you’re doing…
If you re-annotate the schematic, some components may turn out to get different Reference numbers compared to last time, and if you update (F8) the board with “Associate by Reference” it’s gonna get mixed up. In this case, use the Timestamp.
What’s the timestamp? Every symbol that you insert in the schematic gets a unique timestamp. It’s simply a fancy number that probably contains the current Date/time (down to seconds or maybe also miliseconds, that’s not important) … this timestamp then does not change if you re-annotate… that’s all good.
It also does not get copied… if you copy © an existing resistor and place it on the schematic, it will have the same properties as the one it was copied from, but it’ll get a fresh new timestamp (and no annotation).

Anyway… The problem: I’d think the problem is that Cut+Paste probably uses the Copy+Paste functionality…

  • Cut copies a bunch of things you have selected into a clipboard/buffer, but then also get removed from the original place
  • Paste lets you put the stuff from that buffer somewhere in the schematic.
    It makes sense for Paste to insert the symbols as new ones when you’re copying, so the References get cleared, and the timestamps too… you get fresh new timestamps.
    Basically Cut+Paste is not “Move” … there’s no way to “Move” things… Cut+Paste is the closest thing but it erases both kinds of information that can be used to keep the Schematic+Board synchronized.

The technique:

The timestamp can’t be editted, so we’ll have to use the References.
With this technique, you will loose your current Reference numbers (if you care for them).
With this technique, you cannot move many things between sheets in one go.
If you would need new hierarchical sheets - make them now before you start.

  1. Save your schematic and board, make a backup before you begin.
  2. Clear the annotation. (CHECKPOINT1)
  3. Annotate the whole schematic with a simple sorting rule, don’t use the “sheet number X 100” !!! Use the “first free number after 0”.
  4. Inspect the schematic, hopefully nothing has broken (watch out for those multi-unit symbols)
  5. F8 (update board) - Associate by timestamps
  6. Inspect the result - electrical connections shouldn’t have changed, there should be no new footprints, no deleted footprints…
  7. If everything so far is okay - Save schematic and board. (CHECKPOINT2)
  8. Box-select a circuit in the schematic and Cut it.
    If it’s difficult because of surrounding circuits - move it off the sheet into an empty place, don’t re-arange the symbols in it!
    Once you got it all there - box-select it and Cut it.
    Now some components have vanished from your circuit and you probably have “holes” in the annotation (numbers that aren’t used).
  9. Go to a different place - Paste.
    Now you have your circuit back, but it’s “brainwashed” (different timestamps, no annotation)
  10. Partially annotate the missing numbers - use the same rule, keep existing annotations.
    The idea here is that you should “happen to get” the same numbers as those at CHECKPOINT2. This is why it’s important to not re-arrange the symbols during this manouver, nor to try and cut/paste one circuit from A to B, and another circuit from X to Y in one go.
  11. Inspect the schematic…
  12. F8 (update board) - Associate by References!
  13. Inspect the result - there should be no broken connections… etc…

At this point, you can use Timestamps again, but the circuit that you just pasted will NOT get the same numbers if you re-annotate.
Thus, if you have more circuits to “move”, repeat the process from step1 or step2 all the way down to step13, for each circuit.
Once everything is in its new place, you can use Timestamps again and completely re-annotate the schematic the way you want (and F8 - associate by timestamps).

IMO Cut+Paste should have been made to keep the timestamps and reference numbers, and once you Paste - the buffer should get erased so that you can’t Paste the same thing again.

You have correctly added “KiCad5” to the title. In 5.99 there’s better support for cut/paste between schematics. With Paste Special you can keep the annotations.

I just had a very simple idea:

Suppose that if you cut a block (With [Ctrl + x]) from the schematic, it preserves the timestamps and RefDes in the buffer, so if you then paste it somewhere else (in the hierarchy) links to Pcbnew are preserved. and only when you copy a block, then the RefDes is cleared and Timestamps are “randomized”.

So, what happens the second time you paste after cutting? It’s not like pasting after a cut empties the buffer.

I already anticipated that question but it was late yesterday and did not think it completely through yesterday.

Simplest solution is that KiCad checks for conflicts during any paste operation, and resets RefDes and changes UUID’s when it detects duplicates.

My opinion is that combining the normal and “special” paste options into a single paste operation would be slightly preferable, but then there is no room for the “preserve RefDes even if duplicate” question anymore, and this can also have it’s benefits.

I can paste a block into a freshly opened Eeschema instance in standalone mode. That’s a nice improvement in V5.99.

I also experimented a bit with the “Paste Special” in KiCad V5.99. It does not work as I would expect it to. You can indeed preserve the RefDes, but it does change the UUID of all schematic symbols.

A quite common use case is to start with a single page schematic, make a PCB, then for a later revision the schematic gets to crowded and you want to move some parts to a hierarchical design. Then I would expect the UUID’s to be preserved while Cutting a block on a schematic and using “Special Paste” to get it on a hierarchical sub sheet.

I can see two solutions for this:

  1. UUID’s are always preserved unless they generate a collision.
  2. Add a “Preserve sync with Pcbnew” checkbox is added to the “Special Paste” options.

I know it’s possible to re-sync Pcbnew with Eeschema by using the RefDes annotations, but it is an extra conscious step that can go wrong. For example, re-annotating the schematic when changing to a hierarchical design is a logical step to clean up the hierarchy, and if this is done before the re-sync between Eeschema and Pcbnew the links are completely broken and repair is tedious.

I am curious what others think of this. My intention is to raise an issue for this on Gitlab after a few days, and also integrate good ideas posted here.

Yeah, and I was also thinking something similar to that answer. :wink: I must now admit that I was playing Devil’s Advocate to help you fully develop your feature request for GitLab. :smiling_imp:

Sometimes simple ideas are the best.
However, my feeble brain cannot understand your suggestion. I don’t know what a “RefDes” is.
I don’t know what a “randomized” TimeStamp is.
I know that a file in linux has a last modified “date/timestamp”. Please explain.

Sure you do, you just don’t know that you do. :wink: “RefDes” is just short for Reference Designator (the R1, R2, C1, U4, etc). I usually use “Ref’D” to mean the same thing (just because that’s what I used most when I was first learning and using schematic/PCB concepts).

This is simple, but for some reason (probably personal) requires a bigger explanation: Sorry in advance for the wall of words.

What is being referred to as a “timestamp” here has nothing to do with filesystem timestamps. The terminology being used here is a hold-over from past KiCad usage/terminology. Every part you put on your schematic has two hopefully unique identifiers. The visible Ref’D and an invisible identifier. In earlier KiCad this invisible identifier was supposedly the timestamp for when you placed the symbol in your schematic. Currently this is translating into a UUID (universally unique identifier). Either of the two (Ref’D or timestamp/UUID) can be used to link a symbol in the schematic to a footprint on the board. The reason why there are two are because of two ways a part can be changed by the designer.

  1. If for some reason the designer wants to change the Ref’D of a part. For example he wants to change C25 to something more meaningful like C0501 because it is the first bypass cap on U5. (Some higher engineer came up with this wiz-bang method of identifying bypass caps by including two digits for the U-number in the capacitor’s Ref’D, only to be undone on the first board his team designed that has more than 99 non-bypass capacitors…) When updating from the schematic to the board with this new Ref’D, how is PCBNew supposed to know that C25 is actually C0501 and not delete C25 and put a C0501 in the new parts to be placed area? If updating by the timestamp/UUID then PCBNew would know that they are the same capacitor and would just update the Ref’D to the new one.
  2. If, for example, the designer needs to change SW3 switch from a NO (normally open) switch to a NC (normally closed) switch with the same footprint, it is often easier in the schematic to delete the old switch symbol and place a new switch symbol and call it SW3 and assign the same footprint. Now the new symbol for SW3 has a different timestamp/UUID than the original SW3 had. To keep PCBNew from deleting the older SW3 footprint and put the new SW3 in the new parts to be placed area, then one would update by the Ref’D. (Yes there is currently a way around this in at least v5.1, but this example is still a valid way of making changes and feels better to those of us who are used to erasing something that needs to change.)

I hope that helps your understanding, and isn’t more confusing…

1 Like

@SembazuruCDE, What exactly do you mean by this?

@SembazuruCDE, Thank you for explaining. It isn’t confusing because you italicized your parenthetical
comment “(Some higher engineer…”. Had you not done so, my brain would have been driven into endless loops of confusion!

So I grasp that the “Ref’d” designator for my schematic’s first resistor is R1.

Next, I search my schematic file for “R1” and see this:

Wire Wire Line
        5950 3150 6550 3150
L Device:R R1
U 1 1 5BF3138B

Bear in mind I am still ignorant of the format of all these text files.

So the timestamp/UUID for R1 is maybe 5BF3138B ?

Next, I search my .kicad_pcb board file for “5BF3138B” and see this:

(module Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal (layer F.Cu) (tedit 5AE5139B) (tstamp 
    (at 169.35196 96.24568 270)
    (descr "Resistor, Axial_DIN0207 series, Axial, Horizontal, pin pitch=10.16mm, 0.25W = 1/4W, length*diameter
    (tags "Resistor Axial_DIN0207 series Axial Horizontal pin pitch 10.16mm 0.25W = 1/4W length 6.3mm diameter 
    (path /5BF3138B)

AHA! There it is. So I infer that 5BF3138B must be the timestamp/UUID for R1. So that is the “symbol” that links resistor R1 to a footprint in the board file, as I just verified for myself.

That helps. Thank you for taking time to explain.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.