Batch import of schematic symbols / Python scripting for Symbol Editor / CLI for Symbol Editor

I see that the Symbol Editor can import a single schematic library part from an Altium SCHLIB just fine. Quite successfully… Good ! 1 part out of 1000 but, that’s fine - import a part works.
I looked to see in the KiCad CLI if I could run this process from the command line and write a big script to export - import the whole lot. But CLI doesnt seem to support import symbol into a library.
mmmm
How about the Python API I thought ?
I read some old posts about this from 2017 , 2019 but all the documentation links are broken now, too old. I see there are a few private github projects for importing, but that was before kicad could do it itself.
I found that PCB has some doco about Python scripting, but I cannot so far find anything about Python scripting for the Symbol Editor.
I found this class list, KiCad Pcbnew Python Scripting: pcbnew Namespace Reference
but couldnt find anything that looked like what I need.
Any suggestions?
With thanks, glen.

1 Like

Included in the new features https://forum.kicad.info/t/post-v7-new-features-and-development-news/40144 is the below post. I’ve no idea about documentation. You may have to wait for the rest of the world to wake. :slightly_smiling_face:

Thanks JMK
yeah …when I try to do a symbol import, OR a manage symbol libraries (and load the schlib) , it only ever consumes one part in the entire library. there are a few parts ahead (in the altium list ) but they dont import.

A little more information. SO if I import the default supplied Altium library device.schlib , that loads fine.
But it is not as default supplied- that device.schlib has been modified by me perhaps 100 times, so it isnt a ‘fresh’ file. That has 295 items.
If I load my big library glen_sch.schlib, it loads only 1.
If I load my other smaller libraries, they load OK. (3 to 10 items)
My big library has 917 parts in it.

The screenshot above shows whole Altium libraries loaded.
This is accomplished in Preferences > Manage Libraries, but I’ve never imported libraries myself and the last time I dealt with Altium, it was called Protel.

Someone more knowledgeable with Altium library importing should chime in soon.

OK, so if I split my single huge 917 part library into 1 x 406 part library, and another 511 part library, they load just fine.
if I combine them back together, as a new schlib file and paste the objects all in, it works.
but looks shorter in Kicad . well that’s something anyway.
Is there a way I can get the number of parts in a library (to check if they all came in ) ??? IE get a count or symbol report ?

In KiCad 8, you can add all your libraries into the table, then select the rows and click “Migrate Libraries”, which will convert them to KiCad format.

get a count or symbol report ?

Not with builtin functions.

You may search for plugins, I remember a tool which exported libraries to spreadsheets (for easy bulk-editing of symbol fields) and I have seen a plugin/tool which works directly on the library files (for library management?).

I used Notepad++ for some intensive work after importing some libs. There is this flexible search (and replace) function (with regex capabilities). This can count too. In one file or in multiple files. If you search for the start code of a symbol you can let Notepad++ count the appearances of the search string in one file/folder of files…

(k8rc2)
HI all. thanks…
Alright then- Migrate library then see how many directory entries I have - should do it.
Not sure why it didnt like the first large library, will investigate. Something obviously upset the parser.

There are several ways to Count (not including your fingers).
Two examples compare the Schematic’s Python CLI and my coded App.
218 Vs 219 only reflects including/not-including start-line

I’m a bit confused. What do you want to count? Libraries or the symbols?

Seems quite clear . . .

1 Like

yes, symbols / library parts.

actually library parts is a bit of a bad term, because in Altium, you have multiple parts for a symbol (like four gates in a 7402) , even though a library symbol (the whole 7402) is called a part.

I refer to the mentioned solutions that describe how to count the *.kicad_sym files = libraries.

When searching in Notepad++ or other tool capable of searching within files, you get a nice report:

1 Like

Just for ‘Clarification’…

On my system (Mac), a User’s Symbol Library is placed in:
Documents>7.0>symbols

That contains the User’s sym-lib.kicad_sym. This lib contains all the symbols created by User

The Kicad stock symbols are contained in:
Applications>KiCad>KiCad>Contents>SharedSupport>symbols

That contains the Stock Lib’s ( .kicad_sym ) for only the symbols ‘Enabled’ in the Preferences>Manage_Symbol_Libraries. If they’re not Enabled, they won’t show up.

So, the question ‘might be’; How to get the Altium Libs/symbols to list/show-up? Is that correct?

If correct, and they are compatible with Kicad, then Add that Library to the table using the + icon and set the Path to it’s location.

1 Like

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