Plugin to transfer symbol pins to hierarchical labels

I was wondering if there is a plugin/ native Kicad feature that would take all of the pins on a part and add a hierarchical label with the same name.
I used kipart to parse the pinout of a large microcontroller (176 pin STM32H7) I made using STM32IDE, and I want to make a hierarchical sheet for the microcontroller that has all of its needed support circuitry, but has all of the pins accessible via a hierarchical sheet. Is there a way to do this automatically?

The first hurdle to this is the lack of a plugin API in eeSchema in the current (v5.1.9) and all past stable releases. There is a plugin API in the works for v6, but I’m not plugged into the development circles so I don’t know how well (or quickly) that effort is progressing.

This seems like one of those rare occasions where hacking into KiCad files with a text editor is still beneficial.

You can draw one hierarchical label in your schematic, then look at it’s syntax in a text editor, and copy & paste them from KiPart data to the schematic.

(Make sure you have a backup before doing something like this)

Writing a script for it in any scripting language should also be easy. In it’s simplest form it takes a table of data, and ouputs text in a terminal window, which you then manually copy and paste into the schematic file. This gives you the opportunity to use inremental coordinates, so your labels don’t get stacked on top of each other.

Are you aware of the auto increment with the [Ins] key?
If you put a label that ends in a number on a schematic sheet and press [Ins] then it adds a new label with the next number under it. This makes drawing of numbered buses real quick and easy.

This is super helpful! ill post a python script here if I get something that works.

Writing a python script to format some text like this is an excellent beginners project to do something useful with your first program.

You may also have a look at: file_formats.pdf
(The above is a link to an already existing copy on this forum. Some time ago this file disappeared from, and the whole site seems to have some problem today.)

This worked perfectly. If anyone else needs this, here is my code. I made this specificlly for the STM part I was working with, but it would be easy to adapt it to any kipart part.
Just paste the output where the “Hlabels” go in the sch file (after backup ofc).

`import pandas
 excel_files = ['bob.xlsx']
 x = 5950
 y= 900

 for file in excel_files:
      df = pandas.read_excel(file)
      indexp = df[df['Type'] == 'Power'].index
      df.drop(indexp, inplace=True) #ignore multiple ground/VCC pins

      name_col = df['Name']
      label_col = df['Label']
      label_col = label_col.fillna("") # without this NPL will fill with NANs where there is not a user defined label

      df['NPL'] = name_col + "-"+ label_col
      for nc in df['NPL']:
          print ("Text HLabel " + str(x)+"  " +str(y)  +"    0    50   Input ~ 0")

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