Python - list of components on the PCB, and their assigned footprint?

Hi,

anyone knows how to python a list of components so I can check the footprint names ?

for module in board.modules:
        print("* Module: {} at {}".format(module.reference, module.position))

AttributeError: 'BOARD' object has no attribute 'modules'

comming from the doc : List PCB Entities — KiCad 0.1 documentation

thx for your help

That documentation must the the experimental one for the new planned API. I think originally @pointhi made it, but I have no idea if the doc reflects the current state of the API which has not been published at all yet.

This is why I dont like readthedocs.io.

so…how do I fix this ?

listing all components should not be something that cryptic and secret I guess

I have no idea what that readthedocs API is, but it isn’t KiCad official, nor does it reflect some unreleased API that we are working on.

The official docs live at KiCad Pcbnew Python Scripting: pcbnew Namespace Reference

This is linked from PcbNew Plugins | Developer Documentation | KiCad

Hint: It’s called FOOTPRINT not MODULE these days, so if you are finding example code using MODULE, it won’t run in 6.x or above

I can list footprints, but there is no GetName() function, I tried a couple of functions, but I cannot find the name of the footprint itself

		for fp in board.GetFootprints():
			if "keycap" in fp.GetValue():
				wx.LogMessage(fp.GetValue()+" has keycap")

If you’re just wanting to see the footprints and Not make a plugin then, just use the simplified BOM tool

File > Fabrication_Outputs > BOM

or, use one of the scripted BOM’s in Kicad

It points to https://github.com/pointhi/kicad-python, the beginning of the new API in its early stage some years ago. I don’t know if it was used as the base for later development.

yep all my keys are there

yet one the other components inherit of the same footprint…this is clearly a bug, and not an easy one to reproduce

and here is the culprit, and it’s not in the bom

in the schematic editor, it’s not the same packages

image

and since I upgraded from v5->v6 I get weird errors of KISYS3DMOD missing too

(post your file. But, problem may be this: Sometimes when I link a Footrpint, I mess up and add two of them in the panel… worth checking it…)

wish I could share but it’s copyrighted and represent months of work and research and debugging

thought I got rid of these red errors thou

and as I update all footprints, it gets back so it must be in the library itself

I update OSX and Kicad a few months ago and had zillions of problems. Still working through and updating links in older projects with the same problem you have…

yeah this is annoying as hell

I dont know why but “updating footprint from library” is removing my 3D objects on some components

image

Ugh CRUD !! I had a usb connector and a bloody barrel jack here…

image

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