Hey there. I’m looking for some help. For our Coil Generator plugin we want to add a “stats panel” that shows the DC resistance, the inductance etc. To do that, we would like to read the parameters from the board stackup as it already has all the info we need so the user does not have to enter it manually for the calculations.
I’m pretty sure I’m able to access that information via Python because the python bindings seem to expose everything and this looks like what I’m looking for. However I’m unable to get the correct reference.
I think I’m close, but not there yet. The closest I got is:
pcbnew.GetBoard().GetDesignSettings().GetStackupDescriptor()
This returns the following: <Swig Object of type 'BOARD_STACKUP *' at 0x000001C43ADA5050>
with these attributes: 'acquire', 'append', 'disown', 'next', 'own'
I think the issue here is that the StackupDescriptor isn’t actually the stackup that I’m looking for. I already tried looking through the C++ code, through other addons and ChatGPT, none of it helped. I guess something like this is possible, if I knew the correct function names:
board = pcbnew.GetBoard()
stackup_manager = board.GetStackup()
for i in range(stackup_manager.GetCount()):
stackup_item = stackup_manager.GetItem(i)
layer_name = stackup_item.GetLayerName()
thickness = stackup_item.GetThickness()
epsilon_r = stackup_item.GetDielectricConstant()
My current approach is to look through anything that looks promising by printing the result of [method for method in dir(pcbnew.GetSettingsManager()) if method.startswith('__') is False]
. But so far, without any results.
Thank you in advance for any pointers!