Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center finding not accurate due to silk screen #379

Open
dzid26 opened this issue Oct 25, 2023 · 4 comments
Open

Center finding not accurate due to silk screen #379

dzid26 opened this issue Oct 25, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@dzid26
Copy link
Contributor

dzid26 commented Oct 25, 2023

I wanted this to work, because for my footprint anchors are defined at pin1.
Unfortunately, it seems GetBoundingBox takes the silk screen into account.

bbox = footprint.GetBoundingBox(False, False)

As a result for a footprint like this with dot on silk:
image
the calculated center is too low.

@dzid26
Copy link
Contributor Author

dzid26 commented Oct 25, 2023

For Kicad 7.99, this seems to work for some reason without even selecting copper layers:

footprint.GetLayerBoundingBox(footprint.GetLayerSet()).GetCenter()

Alternatively combining boundboxes of each pad works with Kicad 7:

                pads: list[pcbnew.PAD] = footprint.Pads()
                bbox : pcbnew.BOX2I = pads[0].GetBoundingBox()
                for pad in pads:
                    bbox.Merge(pad.GetBoundingBox())
                return bbox.GetCenter()
@Bouni
Copy link
Owner

Bouni commented Oct 26, 2023

@dzid26 are you submitting a PR for this?

Is your approach with combining the bounding boxes of all pads working for V7 and V7.99?

@Bouni Bouni added the enhancement New feature or request label Oct 26, 2023
@dzid26
Copy link
Contributor Author

dzid26 commented Oct 26, 2023

I can submit the PR.

Bounding box logic will work with 7.0.

Should the same logic be applied to SMD components though?

if get_smd(footprint):
I tested it on my old board with SMD footprints as well and it works.

  1. On one hand, I can imagine people having footprints with SMD property set and the anchor at pin 1 (like mine), so they would benefit from the bounding box calculation.
  2. On the other hand, moving anchor relative to footprints can be used to offset component placement in relation to the pads. With the bounding box logic, this would not be possible. However, this would become a moot point if we had a translation correction similar to rotations.
    It doesn't matter to me, because my crappy footprints (imported from Altium) have this property unspecified, so the new logic will apply regardless.
@dzid26
Copy link
Contributor Author

dzid26 commented Oct 26, 2023

In the PR, I prioritized point 1. (I removed if get_smd(footprint)) so that if people have an anchor not in the center, the plugin will help them.
Point 2. I assume that eventually will be solved with translations - moving anchor on the footprint is a big pain anyway in kicad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants