Special Strings or Text on PCB

There already is a bar code generation script in the footprint wizads.

Footprint Editor -> Icon: New Footprint using Wizard -> Icon: Select Wizard script -> BARCODE USS-39


That’s handy… I used that code to generate a barcode from the module value, so you can set the value in eeschema. Well, that is the theory… as soon as I move the module or save file, all my graphics added to the module are replaced with zero length lines…spent a few hours struggling with that and got nowhere!

Also discovered that my scanner will not read Code39 barcodes which have only a single character without changing the setup. :frowning:

1 Like

If you can use nightly there is an option


I miss this, too. I’d like to be able to enter information at the project level (KiCAD’s *.pro file) and have it accessible from at least EESchema and PCBNew, and possibly any of the other tools. I think there’s a case for having defined fields for the bare PCB’s part number, revision designator, and revision date; as well as part number, revision designator, and revision date for the completed PC board assembly. Beyond that, there could be user-defined fields - either a pre-set number of fields, with pre-defined generic names (like “Field1” through “Field8”, or “%F1”, etc) or a totally user-defined name-and-value pair.

With a feature like this I could create a title block in EESchema using a syntax such as “%AsyPN”, “%AsyRev”, etc; then write a drawing note similar to “1. This Assy built on PWB p/n %PCBPN, revision level %PCBRev.”. Then in PCBNew I can etch the PCB part number into copper with just a reference to “%PCBPN”, or write the assembly information to the silkscreen with “Assy # %AsyPN, Rev %AsyRev”.



Oh wow - that’s great news to see, Maui. That didn’t turn up in my initial searches, so I’m glad to see this. I think I am going to have to learn more about python scripts in KiCad. I’m glad there is a sensible scripting system for automation of some tasks!

Exactly my thoughts, Dale. Being able to auto complete this information on board revisions is a boon for those of us who do commercial design.

And you enter it only once - at the project level - and it automagically finds its way to the appropriate places in each of the tools. As you said, a great way to save time and avoid worry if you clone an existing project to create the next revision.



I sorted out my barcode problems, there are some strange interactions between Python and KiCad, including some which crash KiCad :frowning: I also extended the script to read title block data from the schematic.

The %T etc names are taken from KiCad worksheet editor, I didn’t bother with sheet specific data. I think that should handle most use cases, are there any others?

The script could do with some more refinement, e.g. preserving properties of text fields set by the user, passing parameters to barcode generator, implementing action script thing etc.

autofill.py (9.1 KB)


Because I’m on a roll, and Python makes it easy, I implemented some user defined fields. There are other ways to do it, perhaps put the fields into a schematic component would be neater.

autofill.py (9.4 KB)


You can look at the KiPadCheck nightly source for hints on how to implement action script. It’s not perfect yet. I’m unclear how it deals with re-entrance. And I’m not sure if I implemented import vs. reload properly.

When I work out these things, I’ll try to remember to ping you about it. Either way, I’ll put an indicator in the update notes in the main KiPadCheck nightly thread. There are just a few methods you have to implement. I’ve implemented them in a class definition, but you might also be able to put the definitions in the top-level module script.


I’ve written a new script that implements Action Plugin integration for a python script into KiCad. It also happens to be a good example for integration a gui developed in wxFormBuilder. Just a few hundred lines, it contains both gui integration and Action Plugin integration in one simple example.

Thanks @HiGreg, I hope to follow that example when I have time. For now I have pushed what I have got to

I added Code128 barcodes, a more traditional user title block, and the ability to place text in any layer with a %layer prefix. If the user has changed text properties, the script tries to preserve those, so you can move the text or put it on a different layer.

With this script method, it would also be possible to create other dynamic content like read values from a file, import graphics, render system fonts. Maybe even use it to import subcircuits.

I have been having trouble with the layer manager checkboxes and newly drawn objects added to board.Drawings showing up in the view.

When in windows OpenGL canvas, it requires a switch view to default and back for the objects to appear. Haven’t figured out a way around this, but have started several conversations here and on the developers list.

I noticed a method called Refresh(), I haven’t tried it because it is not in 4.0.6 Refresh()

In Default canvas, I zoom in and out and it refreshes the display… I should add that to the user guide!

This all looks great, but I am having a problem with it. I installed KiAutotext (the 4 .py files) in ~/.kicad_plugins, added the contents of Libraries to the project directory, and added the footprint and library paths to the project specific libraries, but something is going wrong there, and also when I load the included example project with kicad 5.0.0-fee4fd1~66~ubuntu18.04.1.

When I use Tools->Refresh Plugins, nothing is listed. What is odd is that I know kicad is seeing it at some level, because when I open any of the footprints in the footprint library editor the corresponding .pyc files appear in ~/.kicad_plugins.

Any idea what is going on here? I’m stumped.


v5 happened :slight_smile: When I have time I will update to the new API, the changes are minor I think.

Silly me, I thought V5 meant it was fixed for all of us teeming masses. I forgot about the joys of major releases. Thanks for coming up with a handy little script!

I’ve pushed a new version of KiAutoText which should be fully v5 compatible, and also now runs as an Action Script under the Tools->External Plugins menu.


FYI, I noticed that the PCBRev and PCBpn fields in the symbol library are reversed.

BTW, thanks for this!!! :grinning: