tfmf1main- Making Folders for Footprints (4-0-4)

create counter

Tutorial: Making Folders for Footprints

(First created while using KiCad version 4-0-4.)

Having your own footprints available to you in your design work is a big help and pleasure.

And it is one of those things that is relatively easy to do… easy relative to the hassles of getting started. Of course there are the "learning curve" issues, but having your own footprints is bad in ways beyond that. Getting set up for having your own folders is a pain.

This essay attempts to help you get set up.

Footprint definitions are held in libraries.

I want to stress that there are two sorts of library: Libraries for schematic symbols and libraries for footprints. Schematic symbols and footprints are similar, but not the same. The files which hold their definitions are similar in some ways, and quite different in others. (I have written a separate tutorial for you on getting started with making your own footprints.)

I won't do as much explaining as I usually do, because this is a "do only once in a while" task. And because the prospect is too daunting!

(You should also get yourself to the point where you can have your own schematic symbols available. That's a similar story, but different in details. A story for another page.)

Bad news

Despite what I have just said, it may seem, particularly in this tutorial, and particularly at the start of it, that I "ramble" an awful lot. If you bear with me, I think it will reward you. The topic we are considering requires a pretty good understanding of what's going in inside KiCad, if you want to do the things explained here without much pulling of hair. There's some abstract stuff going on, and KiCad actually works just fine… the way it was programmed… but not necessarily the way you might assume it is working.

Right.. here we go, then…

Ha! As I was setting down to do this, having spent hours getting on top (I hope) of all that is involved, I had a brilliant idea. What follows is a cheat. And not well tested. But I think it will work!! (It does, in the short term. Whether there are subtle flaws in my cunning plan I will no doubt discover in the weeks ahead.)

I was using KiCad 4-0-4 on a Windows 7 machine when I did all of this.

Be sure everything "KiCad" is shut down.

I let KiCad install itself where it wanted to. It is "buried" in the operating-system-managed "C:\Programs", in a folder called "KiCad-4-0-4"

At the time, I also set up folders in my "Documents" area.

(Why do you see "TKB" in the following? Those are my initials, which, thankfully, rarely turn up. I sometimes put them into folder and file names to distinguish them from things created by the system.)

I use the first ("Project") for my projects, giving each of them their own folder. (Each version of each of project gets its own folder, actually.)

The second ("TKBLib") is for my libraries… collections of schematic symbol definitions and footprint definition.

All of the above was initially set up just with ordinary operating system tools. ("Windows Explorer")

Set up while no part of KiCad was running.

As a first step towards the creation of What You Need, I created another folder: Foot17201.pretty

That was inside TKBLib.

The name was assembled as follows…

  • "Foot" because this is a folder to hold footprint definitions.
  • "17201" because I created the folder on 2017, in the 2nd month, on the first day. Using dates in names can be helpful when trying to figure out where things have come from. (Or gone!)
  • ".pretty" because KiCad requires that at the end of the name of a folder for holding the files which defint footprints. (It is one file per footprint, by the way.) And yes, the "." in that is just part of the name, and doesn't cause any weirdness, because this is a folder name. You would be ill advised to use a "." in a file's name.

TEMMPORARY NOTE: "Foot17201.pretty" had flaws as a name. I will write about them more fully one day. For now, everywhere you see "Foot17201.pretty" think "AtbkFoot17201.pretty". The prefix arises as follows: "A" to put this at the top of some lists, i.e. lists which are sorted alphabetically. Note it must be a capital "A". "a", not "a". (aFile comes AFTER AFile in a list, as sorted by KiCad) "tkb" to flag this as one of my libraries. One I created. (And thus suspect!)

Then I "got clever". Will it come back to haunt me?

To get things started, I copied a footprint definition from elsewhere into Foot17201.pretty. (Details in a moment.)

I did that because something else we need to do in a moment can't be done if the footprints folder you're trying to to it with is empty.

Here are the details of how did the above…

I went off to…

C:\Program Files\KiCad-4-0-4\share\kicad\modules

… where the libraries supplied with KiCad reside. There are eighty seven folders with names ending ".pretty". That's just folders for footprint definitions. They seemed to hold about 20 footprints each, although I found one with 90! (I use the term "XX.pretty" to say "a folder with a name ending .pretty")

Just so you can exactly copy my method, mad or not, I'll be specific. Almost any .kicad_mod file would do for our wants… but one with two pads, like the one I chose, would be best.

I went into Discret.pretty, and from there copied (NOT MOVED!) …
… to the folder I set up earlier (Foot17201.pretty)

Job done! (mostly)

I started up Kicad. We're going to do a few "normal" things now, just to get "in" to the working environment.

I did the things to start a new project. (Called it Tmp4). Created a folder of that name in my …/KiCad-TKB-4-0-4/Project folder. And saved my so-far-empty project in that, again using the name Tmp4.

That, by the way, led to…

  • Tmp4.sch,
  • Tmp4.Kicad_pcb and

(The first two are "shells" for now.)

Then I "designed" a little circuit. It had a resistor and an LED, one end of each joined to the other.

I didn't bother about supplying power. I used schematic symbols "R" and "LED" from the "device" library. Nothing fancy. But I wanted at least one thing needing two pads.

Then I invoked CvPcb, which of course led to the Annotate Schematic dialog. I said "Annotate" (default options), said "Annotate only… cannot be undone." said that was okay with me.

Then CvPcb came to life. Waited about 30 seconds… I haven't "pruned" the number of libraries in use enough yet… but eventually CvPcb was running.

Here's one of the "do only once in a while" bits…

Once I had CvPcb running, and the devices in my circuit… both of them!… were listed int the second column, I invoked "Preferences | Footprint Libraries", which gave rise to….


This is the list of folders KiCad looks in when it sent to find a footprint. We need to add our newly created Foot17201.pretty to that.

I made sure I was on the "Global Libraries" tab. (Tab names on bottom of the tables tab. (Just above the buttons.)

Clicked "Append with wizard". Chose "Files on my computer."

Drilled down to my .pretty folder. (Via "users/(me)/documents/KiCad-4-0-4/TKBLib

Clicked "next". (We wouldn't be allowed to select the folder, even though its name ends .pretty, unless there were at least one .Kicad_mod folder in it. That's why we "messed about" earlier.)

I was asked to review what I was proposing. Said "Next" (It is easy enough to remove a folder from the list later, if necessary.)

Chose to install to Global Library Configuration. (In for a penny…!)

… and, hurrah: the dialog went away, leaving me back at the PCB Library Tables main dialog. (Tables dialog because there's one table for the global (footprint) libraries and a second one for the project's (footprint) libraries.)

I used the left/right scollbar to get to the "description" column in the table, and put something like "my footprints from 17201" there. (It won't appear in some places that it should in until after the next time you shut down and restart all of KiCad, by the way.)

I clicked the "Ok" to close the PCB Library Tables main dialog.

That's most of the "do once in a while" bit DONE!

WHEW! Not "hard", but you need to do it right.

Now we're going to use CvPcb in the routine way for a while, to "exercise" what we've created….

It doesn't much matter what footprints you assign to your LED and resistor to, for the sake of the exercise, but, just for jollies, assign footprint "LED_D3.0mm" from the LEDs library, and something, anything… even the LED footprint… to the resistor.

Save what you've done.

Close and re-open KiCad, saying "yes, save it" any time you are asked "Do you want to save…?"

Re-open the schematic.

Re-run CvPcb. (Remember that the long start up is "normal", if you have the delay I have.)

At this point, you should see "Foot17201" (or whatever you called it) in the list of XX.pretty folders we can collect footprints from. Hurrah! Folder created. And accessed by system!

Just to see that you can, try assigning the "R7" footprint from Foot17201 to the resistor in our "circuit".

Save. Close CvPcb. Generate a netlist. Invoke PcbNew. Read the current netlist.

Move the two components to good places. Put a track on, to connect the right pads. Save.

We've done it! Well part of "it". We've used a component from a folder of our creation!

Now we will make a new component! Well, "new", but derived from the one we have.

Still in PcbNew, use the "Open Footprint Editor" button.

Go to file "File | Set Active Library", and set it to your equivalent of "Foot17201".

Use "File | Load Footprint/ Load From Active Library". "Select by browser" to see all of the footprints there. (Just the one, R7, at the moment.) (Actually, because of the route we followed, we could have loaded from a different library, despite the names on the menu entries. I hope you noticed this? It is not important, if you didn't. It was still necessary to set the Active Direcotry.)

Do something SMALL to the footprint. I suggest adding a short new line, using the "Add graphic line…" tool.

Invoke "File | Save Footprint in Active Library". (You can use Ctrl-S if you prefer.) You will (always) be given a chance to specify a name at this point. Use "MyFirst", for this exercise. You can delete the new footprint later.

Every time you save something, you will be asked for a name. The field will be pre-populated with the last name you used, so it is easy to work in the usual way. But also easy to accidentally overwrite something you didn't mean to.

If you look again at the top tool bar of PcbNew, you'll find a button for "Library Browser". (That will browse the footprint libraries.) It would be a good idea to keep this open while working with the editor. It has several uses, but among them is using it to see if a name is already "taken".

It is okay, by the way, to have, say, two or more "R7"s on the system. You just can't have two R7's in one XX.pretty folder.

To get rid of an un-wanted .kicad_mod file, I used the ordinary OS file management tool. I even did it while KiCad was running. (Footprint) Library Bowser didn't immediately notice, but all I had to do was to go briefly to a different XX.pretty and then back to the one I'd "pruned", and the list of available footprint definitions was updated.

I don't like throwing things out. Deleting files gives me hives. But don't worry… in each project, as soon as you use a schematic symbol or footprint, the system makes a copy of the definition in the project's files. This has many consequences… all good, once you fully understand the system… a topic for another day!

What we've accomplished

We've set up a folder for footprint definition files of our own devising.

We've made KiCad aware of it, so we can work with footprint definitions held there, either "just using" the custom footprints we made earlier, or creating futher derivative works. (It is also possible to create a footprint from scratch.)

It is good that we've set up our own XX.pretty, because we will probably get things wrong from time to time. If they are will in a "corner" of the system like this, it may limit the effect of our mistakes.

What's else must we learn?

Now that the folder exists, we can press ahead with learning about footprint design. There are various things to master, but at least the next things to learn are skills we'll use again and again.

That's not to say that you'll never want to set up another XX.pretty folder… or five… for your own purposes. When you do, just repeat the dodge we used here!

Don't get confused….

There's a lot to learn about using footprints. Suppose, for instance, that you make your own footprint for resistors, and after using it for a bit, you think you'd rather the holes through the pads were a bit larger. You want them larger in future projects, and in any new versions of boards designed before you revised the hole size.

Easy! You just change the hole size in the basic definition of your footprint. Go back to the old project of your choice. Make sure the netlist is up to date. Open PcbNew. Ask to it to read the netlist… but change the election for "Exchange Footprint" from the usual "Keep" to "Change".

That works as follows. Remember I told you that every project keeps a "local" copy of the footprint definition, as it existed when first used by that project? The project uses that copy of the definition to draw the footprints on the board. If you tell the system to change the footprints while loading the netlist, it goes off to the hard disk, and fetches the current definition of the footprint, and replaces the "local copy".

This is just one example of the sorts of things that are great when you are on top of all that is happening… and that are a source of many tears when you are not.

Take another issue.

The project has a local copy of the footprint definition, as I said.

If, on the PCB, you use Pad/Edit (access the correct menu by right-clicking on a pad) to "customize" a pad, that change will be remembered…. in that project, for that pad. Your tweak will "over-write" the "default" inherent in the footprint definition.

(You can even take things in the other direction: Load a tweaked footprint from a project ("board"). (I.e., load it into the editor.) Then save the footprint to a XX.pretty file. (You can use the old name, or a new one, as suits your wants. It really is a remarkably capable system!)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License