Open dzid26 opened 1 year ago
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()
@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?
I can submit the PR.
Bounding box logic will work with 7.0.
Should the same logic be applied to SMD components though? https://github.com/Bouni/kicad-jlcpcb-tools/blob/eca019d8366539c363e5b429c2e8e5bf4560052a/fabrication.py#L116 I tested it on my old board with SMD footprints as well and it works.
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.
I wanted this to work, because for my footprint anchors are defined at pin1. Unfortunately, it seems GetBoundingBox takes the silk screen into account. https://github.com/Bouni/kicad-jlcpcb-tools/blob/eca019d8366539c363e5b429c2e8e5bf4560052a/fabrication.py#L118
As a result for a footprint like this with dot on silk:
the calculated center is too low.