I think there is a sneaky way round it along the lines Greg suggests. If you define a module with a special name, it could be used to identify the type of string. A script like the one above could then update the values accordingly. The module could contain graphics as well as text of course.
A script could certainly read project title, version etc from the schematic file, but I don’t think the script can be run automatically, it would depend on the user invoking it.
Support for other fonts is likely to be a long way off.
I can attach these to different footprints to select where the data goes. In this case the footprints are trivial, they have no graphic items, I’m just using the value. I cheated with the “text on copper” footprint, I had to edit that in a text editor, KiCad deprecates putting text on copper.
The PCB initially looks like this after netlist import:
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!
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!
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 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.
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.
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.
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.
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!