Few of the the old pcbnew Python module's functions are not working in KiCad 6

Hi,

We could see that the below functions of pcbnew module, which was working in the older versions of KiCad stopped working with the new KiCad 6.0 Windows version. It will be awesome if anyone can please help us with the alternative functions of these in KiCad 6.0 or any documents suggesting the new changes in KiCad 6.0?

Functions of pcbnew Python module that is not working in KiCad 6.0

  • pcbnew.GetKicadConfigPath()
  • board.GetBoardPolygonOutlines(outlines, β€œβ€)
  • pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED
  • pcbnew.PAD_ATTRIB_STANDARD
  • pad.BuildPadShapePolygon

pcbnew.PAD_ATTRIB_STANDARD ===> pcbnew.PAD_ATTRIB_PTH
pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED ===> pcbnew.PAD_ATTRIB_NPTH

2 Likes

Thanks Marekr, this helps a lot! Will try with your suggestions.

There is pcbnew.pad.GetEffectivePolygon now…not sure what the difference is really.
and board. GetBoardPolygonOutlines still exists.

I don’t think theres a replacement for GetKicadConfigPath the paths and settings sytem got completely reworked but this old swig api isnt well maintained

Thanks @marekr
pad.BuildPadShapePolygon β†’ pad.BuildEffectivePolygon()
pcbnew.GetKicadConfigPath() β†’ pcbnew.SETTINGS_MANAGER_GetUserSettingsPath()

Now am facing issues with COutline() KiCad application abruptly closes when I use it.

import pcbnew
board = pcbnew.GetBoard()
poly = pcbnew.SHAPE_POLY_SET()
outline = poly.COutline(0)

Any suggestions on this?

Thanks,
Renjith Noel Raj

You need to add an outline first, you are accessing non-existing element.

can you please help me with the sample code?

**This is what I was doing in KiCad 5 ** and it was working fine
poly = pcbnew.SHAPE_POLY_SET()
inflate = pcbnew.wxSize(0,0)
pad.BuildPadShapePolygon(poly, inflate, 16, 1.0 / math.cos(math.pi / 16))
outline = poly.COutline(0)
if (d < min_ring_size):
min_ring_size = d
min_ring = pad

And this in KiCad 6
poly = pcbnew.SHAPE_POLY_SET()
inflate = pcbnew.wxSize(0,0)
pad.BuildEffectivePolygon()
outline = poly.COutline(0)
d = outline.Distance(pcbnew.VECTOR2I(pad.GetOffset()), True) - max_size / 2
if (d < min_ring_size):
min_ring_size = d
min_ring = pad

Used pad.BuildPadShapePolygon in KiCad 5 and pad.BuildEffectivePolygon in Kicad 6

Try poly = pad.GetEffectivePolygon() instead.

2 Likes

Thanks @qu1ck, This helped!!!

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