-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Calculate centroid based on footprint type #117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks great.
Hi. Just a comment on this change, which was breaking for me. |
Please explain how moving the anchor is easier than using offset feature. (I agree that calculating offset based on JLC render is not easy for some reason). Btw, the anchor is still used for SMD type components - this is because they were usually not a problem (the anchor is usually in the center anyway). |
@bleroy I am going make some assumptions, so excuse me if I am mistaken. It seems that you or someone created a footprint that contains two parts - smd LED and PTH MX switch. Another solution, as I mentioned previously, is to change this footprint type to the SMD then the anchor should be used. This is probably preferred for you. Typically, for more complex footprints (horizontal USB-C ports, etc) it is not clear where the fabrication center should be placed so it requires a back and forth with JLC render to either place the anchor or add offset in BOM. |
Splitting the footprint would be a huge hassle, as I would have to position two components where I have one today, and I move these around a lot when working on a keyboard layout. I can try to change it into a SMD footprint again, but as I said in my previous message that didn't work when I tried it. Ideally we'd have a setting to specify what position mode to use, between anchor and pad center... |
I am quite sure JLCPB expects center of pads and not center of footprint bounding box for thourgh-hole-it doesnot work right with bounding box. So we can make it center of pads for anything which is not SMD. (pads center does not always work right for SMD, so it is better the way it is now) |
If "use foorprint anchor" is a global setting, then Kicad library THT components (with anchor on pin 1) wouldn’t work good. But it still could be beneficial for 3rd party libraries. :) |
A "use footprint anchor" footprint field would work for me. |
Rationale
This helps with positioning of thruhole and unspecified component footprint types.
Description
Unlike the smd type, thru hole components in kicad library have their anchor on pin 1. This is an issue because it always requires adding position offset to thru hole components before exporting position file. This update uses bounding box center instead of the default anchor to solve this.
Additionally, I compute bounding box center based on copper pads for unspecified footprint types.
It could be done that way for all type of footprints, as I did in this PR Bouni/kicad-jlcpcb-tools#381 but there they were using bounding box center anyways so the change was less drastic. Here we may still want to use kicad anchor for smt for some compatibility reasons.
I decided to use bounding box center based on copper pads for unspecified footprint types, because I know this type of computation is needed for footprints in projects imported from Altium (which by default are set as unspecified and always have an anchor on pin 1 regardless being SMT or thruhole).
Testing
I tested the change on kicad 7 and 8.
Here is an example of the thru-hole components test.zip from #101:
Before:
After:
Also, as mentioned, I use this change on a project that uses a lot of unspecified footprints imported from Altium and also few SMT components from kicad library.
Compatibility
The most affected projects will be those that used thru-hole components before the change. When regenerating position files with this update, they will most likely have to remove position offset.