How to set/get the module face (board side) with python?

Hi, I am trying to build my first pcbnew script in python. I couldn’t find much information about the pcbnew api. I found the doxygen with the classes, attributes, and methods which is good. But it gives me the same output information that ipython. So, since the documentation is not that good, my question is:

Which method do I use to get which face (top/bottom) the part is placed, and how do I set it to a specific side?

Thank you.

GetLayer() and SetLayer()

Kinda obvious?

1 Like

It is not obvious dude.

My board has 4 copper layers and many other non-metallic layers. So, which one should I use to move the part?

I saw form the .kicad_pcb that the F.cu and B.cu are layers 0 and 31 respectively. But this does not make the parts to move to the top and bottom face.

I actually figured out digging into the code that the methods I need are:

Flip(pos)
IsFlipped()

I tested them and it looks like it is working fine.

1 Like

My bad, SetLayer() doesn’t actually flip. But GetLayer() works.

Have you check this links out ?

http://docs.kicad.org/doxygen-python/namespacepcbnew.html
https://kicad.mmccoo.com/kicad-scripting-table-of-contents/

Edit:
A very recent talk on KiCon about Python

1 Like

Yes! It is hard to find something just by the method name without any description.

And thank you for sharing this:

http://docs.kicad.org/5.1.2/en/pcbnew/pcbnew.html#kicad_scripting_reference

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