Questions about working with Plugins

I’m running KiCAD version 5.1.5 on Windows 10 64-bit. I was tinkering around with Plugins, having never used them before and thought they were kind of cool, and I just finally managed to get them to work. I accomplished this to a limited extent by creating a folder in C:\Users<USERNAME>\AppData\Roaming\kicad\scripting\plugins and putting the 3rd party Python scripts in the folder. However, after this tedious setup, I have some remaining questions about how I can optimize it.

  1. It seems that the plugin only gets loaded when the actual python plugin script is in the folder. I downloaded some plugins by cloning the Github repo and inserted shortcuts to the repos in the aformentioned link above, but it seems that KiCAD doesn’t recognize that. If the only way is to copy the scripts into the folder, how do I manage all of the init files that come with the repos? Should I copy them over or not?

  2. Adding a folder in AppData works in having plugins like above, but I was wondering if there was a way to have it recognize plugins from another location outside of AppData? It would be nice to be able to manage my libraries and plugins in a single folder, but is that possible by adding/changing a KiCAD environment variable somehow?

You’ll have to open a console window as an administrator. Then you cd %APPDATA%\kicad\scripting\plugins and you make a symbolic link to where the plugins really are (e.g. mklink /D replicate_layout D:\complete_path_to\replicate_layout )

As for your first query. The plugins come in two flavours. Simple and complex. Simple ones consist only and only of one .py file. You put this file directly in %APPDATA%\kicad\scripting\plugins The complex plugins can have multiple .py files, but they have at least two .py files. The __init__.py and a plugin .py file. You have to put all of the files of this kind of plugin in its own folder within %APPDATA%\kicad\scripting\plugins`

BTW, speaking as an author of several plugins. The biggest thanks from the users is the contribution to the plugin documentation. As the users are the ones who know best where and how the documentation could be improved.

2 Likes

Thanks for your reply. Is there any harm in creating a symbolic link like that for plugins? Then again, since I had to create my own folder for plugins, it doesn’t sound like there should be any harm in doing so. I’m just not used to manipulating folders in %APPDATA% as it’s usually hidden.

Regarding about what you said about the types of plugins, if you have multiple init files together that correspond to their own respective plugins, wouldn’t they clash with each other since they’re all called init if you have to put them all together in the plugins folder?

You are right to be cautious, but the %APPDATA% folder is writable to user and there should not be any problems (this is how I do it, and I haven’t had any). You only need administrative access to run mklink command as Windows don’t allow ordinary users to run it.

Correct, you cannot have multiple __init__.py files in the same folder. Thus each plugin has to be in its own folder.

1 Like

Also if you don’t want to create a link for every single plugin and want them all to be in a single location of your choosing then you can make the %APPDATA%\kicad\scripting\plugins be a link itself. That way you will only have to do it once.

I’m on Windows and use the link technique for all my plugins (yes, to create the link one needs to open a cmd window in administrative mode). That way I can have the plugins in my github area for easy updating with the github desktop.

Now there are two types of plugins. One is a standalone python file so I just link the python file into %APPDATA%\kicad\scripting\plugins as seen here:

And the other type need multiple files so I link the folder next to the plugins folder in %APPDATA%\kicad\scripting as seen here:


(Those are actually filesystem links, not Windows shortcuts. I don’t think shortcuts will work here.)

1 Like

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