Making A Template For Kicad Projects

Making A Project Template

There are many posts on this subject, this post is in answer to another post, as a singular post for making Templates.

Using Kicad 5.1.5-0 on a Mac.


You can name your Template as desired - Don’t use non-ascii characters in the name (in other-words, don’t use characters like Bullets, Hearts, Stars…, causes problems with Kicad).

• For this example, I used “Tofu” for the name

Steps - Overview:
• Choose a Location for the Template Folder
• Create a Folder named My_Templates
• Create a Project as you normally would
• Create a Folder called “meta”
• Create an Graphic for an Icon
• [optional] Create a Folder named “Out”
• [optional] Create a Custom Worksheet
• Set the Build Path to include the Template Folder

Steps - Detailed:
Note: the ‘optional’ items can be done later and edited anytime.

#0. Create your “My_Templates” folder (or other name) in location that you won’t change.

#1. Create a New Project named “Tofu”
Design a PCB to use as a basis for new projects.
It can feature whatever you want - it’s simply a regular project. So, the Board can have custom Schematic, custom Board Shape… etc.

-Place the “Tofu” template project in the My_Template Folder. The Template Folder will contain all of your Project Template folders.

#2. Create a Folder named “meta” containing Three Items:
• icon.png (a graphic or screenshot representing your project). Size it such that it’s not too big or too small.
• preview.png (another graphic perhaps a screenshot of the PCB or Schematic).
• A Text file Named “info.html” with text you want displayed in the User Templates panel for this Template.

-Place the “meta” folder in the “Tofu” project folder

#3. [optional] Create a Folder named “Out”, for exported Gerbers, etc, if desired. It’s convenient to do this…

-Place the “Out” folder in the “Tofu’ project folder.

#4. [optional] Create a custom Worksheet - A worksheet is the graphic Frame surrounding the Schematic and the PCB. Use the Worksheet Icon Tool in the main Kicad panel. Hack away at it with custom legend, added text and Fields for plugin’s that do things (Example:I have one for ‘Notes’ that fill-in at the click of a plugin button)

#5. Exit the “Tofu” project.
Re-Open the “Tofu” project, open the PCB and Schematic (this ensures that several necessary files get created in the “Tofu” folder Template’s project folder.
Save and close the opened files.

Summary of Above:

A “My_Template” Folder was created containing a Template Project named “Tofu” that contains several files and two Folders (‘meta’ and ‘out’)

#6. Setting the Build Path
With Kicad running, Close all projects/Exit Kicad.
Select ‘Preferences’ from the Menubar, and select ‘Configure Paths’.
A panel will pop-up containing paths.
Click the “ + “ at the panel’s bottom and enter:

Enter KICAD_USER_TEMPLATE_DIR as the name.

Place Cursor in the Entry Field next to it, Click. A Folder Icon will appear on it’s right side. Locate your “My_Template” folder, OK.

Best to Exit Kicad, though clicking the Refresh Icon should make everything happy (if you trust it).

Now, Restart Kicad and create a New Project From Template, and select the User Template Tab…


Screenshots:

4 Likes

Your making of this tutorial motivated me to experiment a bit with making a template.

I quickly patched together 2 templates by:

  • Making a template directory.
  • Copying 2 existing projects into it.
  • Copying the “meta” directory from 2 exising templates (from / usr/share/kicad/template/)
  • Modifying some files a bit.
  • Create a new project from such a template.

And it worked as expected.
It looks like all files directories and sub directories are copied from the “template” project, except the “meta” directory, which is not copied to the final project.

Also the backup files of the schematic, files with personal notes and a sub directory with gerber files (which has the name “gerber/”) is also just copied from the template to the new project.
Files are renamed, but this is also as expected.

I did notice that the first time I had to exit and restart KiCad. (this was before I read this tutorial, just experimenting).

The only “confusing” part is in step #6.
How do you close a project in the KiCad Project manager without exiting KiCad? You can open a project, or create a new, but there is no “close project” button.

Also:
#2. Create a Folder named “meta” containing Three Items:
I’ve seen pictures in there which are referenced from the info.html file, with normal html syntax : < img src = “…”

Should we “WIKI” the first post so it can be group edited?

Re:

Ahh… True, Closing the Project means, Quitting Kicad. (I should have been more clear).

Re:

The ‘meta folder’ contains an info Text file with the extension .html. Html files are files containg XML/text and a host of related items, often used for Web Pages/etc.

You can include what you want but, for a Template, I prefer to keep it simple/plain and use the Icon.png and preview.png for the graphics. Kicad won’t look at the .html for the Icon and Preview graphic.

Re:

Sure - makes sense if the info is understood and clear for others to successfully use.

Done. I’ll add a link to the FAQ.

When you write a tutorial, try to dim down about your “personal preferences” and focus more on explaining how stuff (should) work in an objective / unbiased way.
For example, in #3 [Optional] you wrote about creating the “out” folder, which suggests it’s some special name just like the “meta” folder, but I’m almost certain any folders and data in them is just copied to the project created from the template.

I’ve confirmed this suspicion by just reading the manual :slight_smile:
file:///usr/share/doc/kicad/help/en/kicad.html#_project_templates

All files and directories in a template are copied to
the new project path when a project is created using
a template, except meta .

Where did you get your info for using these templates? Is it just from experience, or did you use other sources too?

I learned about Templates from the same Resource you referred to and from doing it with a multitude of options… and dialed them down to what works consistently.

The point of this tutorial isn’t to educate, perse’ (thus, repeating what’s already written) this tutorial is a ‘Do-As-I-Do’ tutorial that anyone can follow.
From there, I figure an interested user knows how/what to tweak… because they did the homework to educate ‘themselves’, and did some tweaking…

Thus, saw no need to inform others about the filename “out”.

Thanks for your comments

The whole process seems for me ‘too long’ and ‘too complicate’. If I will even follow it once then if after few years I will need to do it once more I will certainly not remember how to do it.

This sentence tells me to not use templates now.
I will wait until ‘Save project as template’ menu button will be available as in my opinion it is the only right way such tasks should be done.

You completely misinterpreted:

The only things I modified was to make those files “unique”, so I could easily verify the right files were used.

For example:

  • I opened the icon.png in a graphics program and put a red stripe through it.
  • I opened info.html and sprinkled some dates in ISO 8601 format through the text.

All of the changes were cosmetic.

So just try it, it takes about 10 minutes:

  • Make empty template directory.
  • Copy an existing project into it.
  • Copy the meta folder from one of the existing templates into it.
  • Set: KiCad / Preferences / Configure Paths / KICAD_USER_TEMPLATE_DIR
  • Exit and restart KiCad.
  • ** KiCAd / File / New / Project from Template / User Templates (tab)**

Ah, now I have it open…
Here a screenshot of the red through the icons and the Dates I sprinkled through the html:

Maybe if someone could type faster, it would take less time… :stuck_out_tongue_winking_eye:

Now I see. Previously I understood that you have to do some modifications may be in source code of something.

Didn’t did it, but I understand how to do and what is the effect.
To use it as it is intended to I understand that I should probably prepare an icons identifying my templates and some html describing them (15 years ago I have exported one OpenOffice file as html - it was my first and last contact with html).
I think I will stay with my way of doing this. I have done some projects with PCBs fit to cases I use. Then to start new project just copy and rename the project.

Indeed, for your own use the templates do not add very much, they could at most shave a few minutes from a whole project.
The slight advantages are:

  • No need to browse to the old project.
  • No messin’ with the file mangler.
  • No need to rename all the project files manually.

The templates could be really useful if there is some mechanism to share them with others over the 'net, but that would get close to something like:

That page seems to be “stuck” at around 50 projects for several years, so what’s left are the usual search engines, and “lucky finds”.

Thanks to the Interactive HTML BOM Plugin you can also search in google for “ibom.html” and preview some nice stuff:

https://westlicht.github.io/performer/build/ibom.html
https://keybase.pub/finwood/ht/ibom.html

it doesn’t always work directly or straightforwar (specially github or gitlab):

https://git.card10.badge.events.ccc.de/card10/hardware/blob/c5b631a4244763965227cac9b5ff8ede1bc03704/boards/Fundamental-Board/bom/ibom.html

https://mirrors.spacecruft.org/openscopeproject/InteractiveHtmlBom/src/commit/1a3c290d411be702c0238e6de5391d727bca0c96/InteractiveHtmlBom/ibom.html

FYI…

The info.html can contain XML to display what you want, as would a webpage No special editor needed, simply do it with any text/document creating program, such as (Word, OpenOffice, TextEdit… etc).

Save it as .html, instead of .txt or .rtf

Example:

Very, very slight.

I have the separate directory named ‘Cases’ and there the projects named according to case names. So it is not a problem “Where the hell did I use it” :slight_smile:

In FreeCommander it is very simple and fast:

  • you select all project files by pressing two keys ‘+’ then ‘Enter’.
  • to copy them to the second directory (you always have two directories visible) you:
    • press ‘F5’,
    • modify *.* to NewName.*,
    • press ‘Enter’ (or click [Execute] key).

Done - all files are copied as NewName with old extensions. In those ‘template’ projects I don’t have any rescue files which would need be renamed separately.

As if being invoked by the conversation:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.