Summary:
- Where are the constants or at least the values defined for PCB_LAYER_ID
- Where is TEXTE_PCB in the Doxygen doc, and if it’s not there, why, and in that case also how does it work anyway?
Details
I am writing a script to run in the PCBNew console to add some text to a board, using the following code:
import pcbnew
pcb = pcbnew.GetBoard()
[…]
txt = pcbnew.TEXTE_PCB(pcb)
txt.SetText(“Hello”)
txt.SetPosition(pcbnew.wxPoint(mm_to_nm(40), mm_to_nm(20) ))
txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
txt.SetTextSize(pcbnew.wxSize(mm_to_nm(10), mm_to_nm(10) ))
txt.SetThickness(mm_to_nm(1) )
pcb.Add(txt)
pcbnew.Refresh()
So far so good. But I want to set it to a particular layer, which probably involves txt.SetLayer(aLayer) where aLayer is evidently of type PCB_LAYER_ID.
Trouble is, I can’t find any docs on what the PCB_LAYER_ID type is. It may well be an enum, and possibly just accepts integers. But where are those integers defined, or where are constants defined for them?
Which leads me to the puzzle about the Doxygen API docs at
https://docs.kicad.org/doxygen-python/
I can’t find any definition of PCB_LAYER_ID, nor for that matter (and more disturbingly) TEXTE_PCB. Yet strangely the code above with TEXTE_PCB in it does work.
I’m pretty sure TEXTE_PCB should be a class in namespace pcbnew, and pcbnew.TEXTE_PCB() is an initializer. But looking it up that way I don’t find it. And it also does not appear in the source code that the docs refer to at https://docs.kicad.org/doxygen-python/pcbnew_8py_source.html
So I’m at bit confused. I might suspect that the docs are out of sync with actual shipping kicad’s API (I have the latest Kicad 5.1.9 installed). But if that was the case how does pcbnew.TEXTE_PCB(pcb) work? Does the API have dynamic dispatching for functions it doesn’t have pre-connected?