I have spent the past week or two writing a command line utility called RenumberKiCadPCB.
It allows you to automatically renumber all the reference designators on the PCB then it goes back and updates the schematic accordingly.
It is sort of an independently developed update of Kren, which does not appear to support new KiCad file formats.
There are a a choice of rules, including separate sorts for front and back. It is very flexible with a number of options including Front and Back prepend strings, etcâŚ
I have carefully tested the software on my own designs but the true test is when other people will use it.
There source is written in very basic âcâ and is available as a single source file to make it easy to make. So you should be able to easily compile it on any platform such as Linux for which there is a gcc or equivalent compiler.
Thanks. I tried using the other script but I could not get it to work. Not only does he require you load his own fork of Kicad Python but I am pretty weak on Pyton so I couldnât debug the problem.
So I tried and tried and could get it to work at all and realize I could probably write my own standalone, fully featured utility in less time so I did.
Please let me know if you have any questions regarding the source, etcâŚ
When you do annotation in schematic its done according to symbols position on the schematic. To me (and some other people I guess) this is not very useful when soldering the PCB.
This program allows you to do annotation in the pcb, so that components are sorted according to their position in the PCB. When you are looking for, lets say, component named R1 you know that it should be on the top side of the PCB and very close to the top left corner.
Usually you place the components on the PCB then you want them in order (top to bottom right to left). Then you move that numbering scheme back to the schematic so when you want to locate, for example, R24 on the PCB you know where to look.
This not only renumbers the PCB automatically it back-annotates the schematic.
I forgot to mention I updated the files at https://documenteddesigns.com/kicad-pcb-renumbering-utility/ to include the instructions to make the program under linux and to correct two warnings which gcc reported which did not show up under Windows/Eclipse and correct a minor bug which resulted in the run time being miss-reported if the process was aborted.
This is what I get when I run the Python Script I mentioned
PyCrust 0.9.8 - KiCAD Python Shell
Python 2.7.10 (default, Jul 8 2015, 15:10:39)
[GCC 5.1.0] on win32
Type âhelpâ, âcopyrightâ, âcreditsâ or âlicenseâ for more information.
import sys
sys.path.append(âC:\BP Sync\Downloads\kicad-python-masterâ)
execfile(âC:\BP Sync\Downloads\kicad-python-master\examples/pcbannotate.pyâ)
Traceback (most recent call last):
File ââ, line 1, in
File âC:\BP Sync\Downloads\kicad-python-master\examples/pcbannotate.pyâ, line 31, in
from kicad.pcbnew.board import Board
File âC:\BP Sync\Downloads\kicad-python-master/kicad/pcbnew/board.pyâ, line 24, in
from kicad.pcbnew import module
File âC:\BP Sync\Downloads\kicad-python-master/kicad/pcbnew/module.pyâ, line 26, in
from kicad.pcbnew.pad import Pad
File âC:\BP Sync\Downloads\kicad-python-master/kicad/pcbnew/pad.pyâ, line 30, in
class PadShape(IntEnum):
File âC:\BP Sync\Downloads\kicad-python-master/kicad/pcbnew/pad.pyâ, line 34, in PadShape
RoundedRectangle = pcbnew.PAD_SHAPE_ROUNDRECT
AttributeError: âmoduleâ object has no attribute âPAD_SHAPE_ROUNDRECTâ
I tried this new forked Python version from the link quoted, with some minor quick edits to run on the loaded-design file, and it gives this from KiCadâs command -
execfile("C:\KiCad_Python\PCB_ReAnnotate\pcbannotate.py")
Re-naming Q1 -> Q101
Re-naming Q4R44 -> Q4R101
Re-naming Q3 -> Q102
Re-naming U1 -> U101
Re-naming U2 -> U102
Re-naming U2R34 -> U2R101
Skipping: Q4R44M.
Skipping: U2R90M.
Re-naming Q2 -> Q103
Skipping: U1MV.
Skipping: U1M"VJ.
Skipping: U3R34M.
PCB annotated.
execfile("C:\KiCad_Python\PCB_ReAnnotate\pcbannotate.py")
Skipping: Q4R44M.
Skipping: U2R90M.
Skipping: U1MV.
Skipping: U1M"VJ.
Skipping: U3R34M.
No changes were made! This is normal if your components were already named in correct order.
By the way I did some further changes to cculpepperâs version. Now it works when called from kicadâs console and I also changed numbering scheme back. It should start naming components from number 1. Here is my fork.
@Joan_Sparky I had filed a feature request for running python scripts from the GUI, but it didnât get any attention from the devs.
@DocumentedDesigns Iâm sorry we have disappointed you in that regard. My intention were to help you. But I want to mention that; nowadays the preferred way to share an open source application is to upload it to a public site such as github or bitbucket. Iâm pretty sure that would increase the interest in your code.
a second thing that I would like to ask is the ability to have a button
to be configured to execute a python file as if it would be invoked in
pcbnew python consoleâŚ
That would make the way to execute a python script inside pcbnew more
human than geekâŚ