python module.GetCenter() doesn't return the center of footprint

Bug #1840501 reported by Matt Anderson on 2019-08-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Low
Unassigned

Bug Description

Maybe this is intended, but if so, it is an unfortunate name. GetCenter() seems to return the coordinates of whatever is at 0,0 in the footprint editor. As far as I know that is what GetPosition() returns as well. I expected it to return the geometric center of the footprint, which can be had by module.GetFootprintRect().Centre(). This can easily be verified on any footprint which is built without the origin being at the geographical center of the footprint. Often times pin 1 is at the 0,0 of the footprint(in the footprint editor).

I think this is true of all versions, but for sure
Application: KiCad
Version: 5.1.3-ffb9f22~84~ubuntu18.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Platform: Linux 5.0.0-25-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.22
    Boost: 1.65.1
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.58.0
    Compiler: GCC 7.4.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

tags: added: pcbnew
Wayne Stambaugh (stambaughw) wrote :

@Matt, unfortunately it returns the anchor position of the module. It looks like someone forgot to override this in the MODULE object to return the geometrical center of the footprint which is what MODULE.GetFootprintRect().Centre() does. Technically you are correct but I'm reluctant to change this for fear of breaking something due to MODULE::GetCenter() being used incorrectly somewhere else withing KiCad.

Changed in kicad:
status: New → Triaged
Matt Anderson (wmattanderson) wrote :

Understood, I just wanted it noted somewhere as it caused me a lot of confusion when trying to generate xyrs data.

Wayne Stambaugh (stambaughw) wrote :

I took another look at this and it looks like someone started to implement a method to get the geometric center of an object but only implemented for SEGMENT objects. We really should fix this. The base object GetCenter() implies that it returns the geometrical center of an object with a warning that the default returns the position of the object.

Changed in kicad:
importance: Undecided → Low
milestone: none → 6.0.0-rc1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers