Wishlist: Integrate RenumKiCadPCB

Bug #1748205 reported by Brian Piccioni
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Unknown

Bug Description

I don't know how else to ask this but I wrote a c program RenumKicadPCB which renumbers reference designations on the PCB geographically and back annotates the schematic. A few bugs have come up and have been fixed. It is very fast and flexible, works with nested sheets, and so on. You can select various numbering schemes, different top and bottom ref designations, and so on.

The source can be downloaded at www.documenteddesigns.com. I wrote it as a single module to simplify the same code base for Windows/Linux/IOS.

The only issue is that it uses a command line/text menu rather than a GUI. I do not know how to write GUI code or c++ so the whole thing is written in well-documented c.

Lack of back annotation and renumbering is a chronic problem with KiCad (I love the software by the way).

I believe my code could be ported to Kicad with minor effort by somebody who is familiar with the GUI. At a minimum, a simple GUI menu with file pick that calls RenumKicadPCB with the parameters filled would be all that is needed.

The way the code is written, it makes a copy of the schematic and PCB files so ideally it would be invoked with PCBNew and eeSchema closed from the main Kicad menu.

I would be delighted if we could work on this. As I said, the code is written, works, appears solid, it just needs a GUI and, possibly integration with the Kicad menu.

Please feel free to contact me to discuss. The code is in us "in the wild" and people seem to like it.

regards

Brian Piccioni
<email address hidden>

Revision history for this message
Tomasz Wlostowski (twlostow) wrote : Re: [Bug 1748205] [NEW] Wishlist: Integrate RenumKiCadPCB

On 08/02/18 15:46, Brian Piccioni wrote:
> I don't know how else to ask this but I wrote a c program RenumKicadPCB
> which renumbers reference designations on the PCB geographically and
> back annotates the schematic. A few bugs have come up and have been
> fixed. It is very fast and flexible, works with nested sheets, and so
> on. You can select various numbering schemes, different top and bottom
> ref designations, and so on.

Hi Brian,

We can do that when the V5 stable release is out. Please open a feature
request ('wishlist') on the bug tracker. A mockup of the GUI would be
also welcome, you can attach it to the request.

Regards,
Tom

Revision history for this message
Brian Piccioni (br0an) wrote :

Thanks. I'll try track that down.

I really wish I could do the GUI myself but I'm old ☹

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Tomasz Wlostowski
Sent: February 8, 2018 10:03 AM
To: <email address hidden>
Subject: Re: [Bug 1748205] [NEW] Wishlist: Integrate RenumKiCadPCB

On 08/02/18 15:46, Brian Piccioni wrote:
> I don't know how else to ask this but I wrote a c program
> RenumKicadPCB which renumbers reference designations on the PCB
> geographically and back annotates the schematic. A few bugs have come
> up and have been fixed. It is very fast and flexible, works with
> nested sheets, and so on. You can select various numbering schemes,
> different top and bottom ref designations, and so on.

Hi Brian,

We can do that when the V5 stable release is out. Please open a feature request ('wishlist') on the bug tracker. A mockup of the GUI would be also welcome, you can attach it to the request.

Regards,
Tom

--
You received this bug notification because you are subscribed to the bug report.
https://bugs.launchpad.net/bugs/1748205

Title:
  Wishlist: Integrate RenumKiCadPCB

Status in KiCad:
  New

Bug description:
  I don't know how else to ask this but I wrote a c program
  RenumKicadPCB which renumbers reference designations on the PCB
  geographically and back annotates the schematic. A few bugs have come
  up and have been fixed. It is very fast and flexible, works with
  nested sheets, and so on. You can select various numbering schemes,
  different top and bottom ref designations, and so on.

  The source can be downloaded at www.documenteddesigns.com. I wrote it
  as a single module to simplify the same code base for
  Windows/Linux/IOS.

  The only issue is that it uses a command line/text menu rather than a
  GUI. I do not know how to write GUI code or c++ so the whole thing is
  written in well-documented c.

  Lack of back annotation and renumbering is a chronic problem with
  KiCad (I love the software by the way).

  I believe my code could be ported to Kicad with minor effort by
  somebody who is familiar with the GUI. At a minimum, a simple GUI menu
  with file pick that calls RenumKicadPCB with the parameters filled
  would be all that is needed.

  The way the code is written, it makes a copy of the schematic and PCB
  files so ideally it would be invoked with PCBNew and eeSchema closed
  from the main Kicad menu.

  I would be delighted if we could work on this. As I said, the code is
  written, works, appears solid, it just needs a GUI and, possibly
  integration with the Kicad menu.

  Please feel free to contact me to discuss. The code is in us "in the
  wild" and people seem to like it.

  regards

  Brian Piccioni
  <email address hidden>

To manage notifications about this bug go to:
https://bugs.launchpad.net/kicad/+bug/1748205/+subscriptions

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

This would be a great feature for KiCad but I'm less than thrilled about using an external executable to do it. I would prefer that this be integrated into the board editor. Given that we have support for passing information between the schematic and board editors, using an external tool doesn't really fit into what most users expect from KiCad. I'm not flat out rejecting it but it will take a lot of convincing to make me accept another external executable when I'm trying to find the time to eliminate the external executables that we already have.

Changed in kicad:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Brian Piccioni (br0an) wrote :

I am sorry but I keep getting a bounceback from my email.

I'll reply here.

I only suggested an external executable because I don't know how to write c++ so I could not integrate the code myself.

The code is standalone but could easily be integrated by somebody who can essentially make a call to the module. All it does is scan the schematic and PCB files, build conversion tables, update the PCB and schematic based up on the rules. It also produces log files to help me debug but those can be eliminated. Because schematics essentially recurs I do several passes to avoid being a memory hog.

It would be a bit easier to do it internal to Kicad because the GUI would only have to know a few parameters like sort direction, different top and bottom reference designations, etc. I figure the GUI would consist of selecting only items 2-9 in the text box I've attached. Most uses would use simple defaults like the ones I show.

This only issue, besides a GUI, is that the way I wrote it I needed to close the starting files to avoid file conflicts. All this could be done internal to Kicad even though I suggested making an external call. That is not required by the program structure.

This would be really easy to do if I just knew a bit of GUI and c++ (to tie into KiCad) but I don't.

Revision history for this message
Brian Piccioni (br0an) wrote :

To try a proof of concept for integration with PCBNew.
1) Prepare an argv, arc style array with the parameters set as per the command line version.
2) Assuming the root schematic and PCB name are the same as the project name: save whether a schematic is open, close whatever schematic is open. Close the file in PCBNew.
3) Call RenumKiCadPCB as an external function with the standard argc, argv c style array.
4) If no error returns, open the PCB file and open the last schematic (assuming one was open) which was open before invoking RenumKiCadPCB.

The standalone application is about 112K in Windows, fully self contained. The routine usually executes in less than 1 second but I haven’t tried on really large designs. Most of the delay is the text output so I would be surprised if even large files take more than 20 seconds.
Currently RenumKiCadPCB commits changes even if there are errors (typically a part is present in the schematic and not in the PCB or vice versa). In a production version, there would be a “commit/abort on error” option.

That’s all there is to it.

Format of the command line to be passed
-iInfil the Input file names (infile.kicad_pcb or infile.sch), usually the project name

-fs Front sort direction
                -fs[1ST][2ND] where [1ST or [2ND] are TB (top to bottom) or LR (left to right)
                DEFAULT is fsTBLR (top to bottom, left to right)

-bs Bottom sort direction same arguments as -fs
  DEFAULT is bsTBRL (top to bottom, right to left)

-j Set the Jog or the variability (+/-) between when a location is the same
                (i.e 0.1 and 0.15 are the same if jog is 0.5. –j0.1 means 0.1mm jog.
                Default is 1mm. This is needed so minor positioning errors do not impact numbering)

-fp Top refdes prepend string (i.e. tpT_ means R1 will be T_R1 if it is on top side
                DEFAULT is empty

-bp Bottom refdes prepend string (i.e. bpB_ means R2 will be B_R2 if it is on bottom side
                DEFAULT is empty

-fr Top refdes start value (i.e. fp100 means parts will start at 100 on the front side
                DEFAULT is 1

-br Bottom refdes start value (i.e. br100 means R2 will be R102 if it is on bottom side
                DEFAULT is to continue from the last front refdes

-m Sort on module location. Default is sort on Ref Des Location

-c Show change plan but don't update files if error.

tags: added: eeschema feature.request pcbnew
Revision history for this message
Brian Piccioni (br0an) wrote : RE: [Bug 1748205] Re: Wishlist: Integrate RenumKiCadPCB
Download full text (3.2 KiB)

I'm the author of this suggestion so I thought I'd provide a status update.

I have re-written the standalone application in c++ (though, obviously, not at as professional a level as I'd like) and it now works inside wxWidgets.

This experience has allowed me to begin to work on Kicad source code. I have figured out how to run debug sessions directly outside my IDEs, etc..

I can see a clear path to modifying PCBNew and eeSchema to provide the renumbering functionality under V5 as a prototype. It will doubtless take me a few weeks to actually implementing it but I understand exactly what I have to do and the question will be one of getting my modified files to compile and link in to the various components needed to add a new function to Kicad.

Of course, the lead devs had indicated the V6 will include back-annotate functionality but I haven't seen where the hooks and function calls are described or documented.

Nevertheless, I am confident that the function is a useful one and will be appreciated by he user base. I hope to be able to contribute it in due course.

Brian Piccioni

-----Original Message-----
From: <email address hidden> <email address hidden> On Behalf Of Michael Kavanagh
Sent: May 4, 2019 3:35 PM
To: <email address hidden>
Subject: [Bug 1748205] Re: Wishlist: Integrate RenumKiCadPCB

** Tags added: eeschema feature.request pcbnew

--
You received this bug notification because you are subscribed to the bug report.
https://bugs.launchpad.net/bugs/1748205

Title:
  Wishlist: Integrate RenumKiCadPCB

Status in KiCad:
  Triaged

Bug description:
  I don't know how else to ask this but I wrote a c program
  RenumKicadPCB which renumbers reference designations on the PCB
  geographically and back annotates the schematic. A few bugs have come
  up and have been fixed. It is very fast and flexible, works with
  nested sheets, and so on. You can select various numbering schemes,
  different top and bottom ref designations, and so on.

  The source can be downloaded at www.documenteddesigns.com. I wrote it
  as a single module to simplify the same code base for
  Windows/Linux/IOS.

  The only issue is that it uses a command line/text menu rather than a
  GUI. I do not know how to write GUI code or c++ so the whole thing is
  written in well-documented c.

  Lack of back annotation and renumbering is a chronic problem with
  KiCad (I love the software by the way).

  I believe my code could be ported to Kicad with minor effort by
  somebody who is familiar with the GUI. At a minimum, a simple GUI menu
  with file pick that calls RenumKicadPCB with the parameters filled
  would be all that is needed.

  The way the code is written, it makes a copy of the schematic and PCB
  files so ideally it would be invoked with PCBNew and eeSchema closed
  from the main Kicad menu.

  I would be delighted if we could work on this. As I said, the code is
  written, works, appears solid, it just needs a GUI and, possibly
  integration with the Kicad menu.

  Please feel free to contact me to discuss. The code is in us "in the
  wild" and people seem to like it.

  regards

  Brian Piccioni
  <email address hidden>

To manage notifications abo...

Read more...

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Brian, all two way communication between the board and schematic editors happen using the ExpressMail() and KiwayMailIn() methods derived from the KIWAY base class.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

KiCad bug tracker has moved to Gitlab. This report is now available here: https://gitlab.com/kicad/code/kicad/-/issues/2104

Changed in kicad:
status: Triaged → Expired
Changed in kicad:
importance: Wishlist → Unknown
status: Expired → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.