Get "Description" field with a python command

Hello everyone! I’m writing a Python script to prepare all the necessary manufacturing documents. What I’m currently struggling with is how to extract the “Description” field from the .kicad_pcb file.

I noticed that there’s a description field in the .kicad_pcb file, coming from the schematic. Here’s what it looks like in the file.
(extract from a footprint)

	(property "Description" "CER 10nF 10% 50V X8R 0603 B000055428"
		(at 0 0 0)
		(layer "F.Fab")
		(hide yes)
		(uuid "06d0d4d9-157e-4d0a-9f5d-ea7a029ac528")
		(effects
			(font
				(size 1.27 1.27)
				(thickness 0.15)
			)
		)

I could obviously retrieve the information directly by reading the file in Python, but that’s obviously not the right method.
I can’t find the correct method using pcbnew / GetFooprints / etc…
If anyone can help me…

Thanks.

In case you use the new IPC API, check out the docs. It is probably in here: Board - kicad-python documentation

Edit: Oh, you don’t mean the footprint description. Let me check again

Edit2: I’m unable to find this field in the docs. However, I might be missing something

I just have found the solution.

import pcbnew
pcb = pcbnew.GetBoard()
footprints = pcb.GetFootprints()
for fp in footprints:
    des = fp.GetFieldByName('Description')
    des_txt = des.GetText()
    print('Footprint Description: %s'%(des_txt))
1 Like