TypeError: GetEffectivePolygon() missing 1 required positional argument: 'aErrorLoc' in KiCad 7.0.9 V

Hi,
GetEffectivePolygon() was working fine in the early versions of KICad but started failing with the below error in the current version 7.0.9

Error:
TypeError: GetEffectivePolygon() missing 1 required positional argument: ‘aErrorLoc’

Requesting help to find resolution on the above issue. Am not sure how to create type of ERROR_LOC

Thanks in advance!

Renjith Noel Raj

When KiCad has to generate a polygon from circles and/or arcs it must approximate them with short segments. The shorter the segment the less error, but there will always be some error. GetEffectivePolygon() wants to know if you want that error outside the shape (so it will be slightly larger than a “perfect” shape) or inside. (Outside is 0, inside is 1.)

Thanks @JeffYoung !!
I tried below
poly = pads[0].GetEffectivePolygon(aErrorLoc=1)
poly = pads[0].GetEffectivePolygon(aErrorLoc=‘1’)
but am stopped with error TypeError: in method ‘PAD_GetEffectivePolygon’, argument 2 of type ‘ERROR_LOC’

Am trying to find how create datatype of ERROR_LOC or if am doing something wrong here.
Am not able find the same from documentation too

Going by this definition, try using ERROR_INSIDE instead.

Thanks @der.ule !!

Still the same issue.

it is not a STRING, it is a data type, remove the “” … I guess.

From the docu

MergePrimitivesAsPolygon(PAD self, SHAPE_POLY_SET aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE)

if we remove " we will end up in “not defined” error, need to know which class/module has the ERROR_LOC defined. So that we can use them.

poly = pads[0].GetEffectivePolygon(aErrorLoc = ERROR_INSIDE)
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘ERROR_INSIDE’ is not defined

On the C side it’s defined here: KiCad PCB EDA Suite: geometry_utils.h Source File but not sure how that maps to python.

geometry_utils.h probably needs to be exposed to SWIG somehow. Sadly I don’t have a clue how to do that…

Probably needs an include like this common/swig/math.i · 7.0 · KiCad / KiCad Source Code / kicad · GitLab

Thanks @Jonathan_Haas, @JeffYoung and @qu1ck !!

But unable to import those in Python.

Please let me know if there is a way I can use them in external plugins built using Python and pcbnew.

Anyone used those SWIG modules in Python?? we are still looking for solution.

I am having the same issue when using the TransformShapeToPolygon function, I need to pass a an argument of the ERROR_LOC type but cannot set it.

This was fixed in the 7.0 branch a few days ago - the fix will be in 7.0.10 whenever that is released. Today you can download a 7.0.x testing build which will have the fix (see commit here: Add default parameter to GetEffectivePolygon() (fc86de34) · Commits · KiCad / KiCad Source Code / kicad · GitLab)

1 Like

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