KiCad / kicad-library-utils

Some scripts for helping with library development
GNU General Public License v3.0
128 stars 95 forks source link

Check if courtyard is closed #284

Closed cpresser closed 5 years ago

cpresser commented 5 years ago

Related #277

JacobEFO commented 5 years ago

Hi @cpresser

I for the fun of it fiddled around with your PR here. Your solution seems to be working well with square courtyards: Take for instance: DFN-10-1EP_2x3mm_P0.5mm_EP0.64x2.4mm image With a corresponding check_kicad_mod.py output: image When we open the courtyard: image

But, if we give it a round courtyard: image The check_kicad_mod output becomes: image

If arcs with a 360 degree turn-around is used, the corresponding output is still "Courtyard should be closed".

An additional feature could maybe be, if it returns the coordinates at/around which the error is generated?

cpresser commented 5 years ago

Hi @JacobEFO

If arcs with a 360 degree turn-around is used, the corresponding output is still "Courtyard should be closed".

The previous commit should fix that. For arc, the start-point was not extracted correctly. Now it does calculate the actual start point. I have tested it with:

An additional feature could maybe be, if it returns the coordinates at/around which the error is generated?

Actually, that's already implemented. Use "-vv" to show the extraErrors. They contain the line/arc that failed the check

JacobEFO commented 5 years ago

Hi @cpresser

Btw I am not a librarian, I just randomly checked out your implementation and found the error.

Seems like you did test it thoroughly though.

Ah, apparently -v does not catch all the errors. Lol. Good call.

poeschlr commented 5 years ago

For testcases regarding courtyards with arc sections look in the battary holder library.

poeschlr commented 5 years ago

Something to keep in mind for arcs: The kicad file format is a bit limited. It is nearly impossible to create precisely closed outlines when arcs get involved (unless you have them only with n*90 degrees) This is the reason why kicad allows for some tolerance to count an outline as closed (I think the tolerance is 0.01mm.) Meaning we might want to have this tolerance allowance also for this check. (But i would only allow it for arcs.)

cpresser commented 5 years ago

Hi @poeschlr Thanks for the hint. I made a new commit that explicitly has the 0.01mm tolerance for arcs. The value of 0.01 seems to be okay, since that's the grid requirement. However, I could not find it in KLC directly.

Indeed, the footprint "BatteryHolder_Keystone_103_1x20mm" will fail this check. It has some points that are about 0.12mm apart. Most likely its the same for similar parts. Currently I don't see a way to make those footprints pass this new test.

IMHO, it is possible to make them fit with that 0.01mm tolerance or less. With a calculator, pen and paper. But the editor is indeed limited.

For 90° or 45° arcs I did some tests. Also for arc-line and arc/arc combos that are not exactly on the same endpoint.

0.05mm Distance Example

cpresser commented 5 years ago

Force push, I did test with 0.1mm and left that value in. Fixed with the force push.

poeschlr commented 5 years ago

0.1mm is a bit large if kicad uses 0.01 ;)

cpresser commented 5 years ago

it is set to 0.01mm with the last commit. See line 121 in the changed file. The comment was not that clear, sorry.

Shackmeister commented 5 years ago

@cpresser @poeschlr Any remarks on this? from my testing it seems to work fine

cpresser commented 5 years ago

right now I consider this done. I am not aware of any issues.

cpresser commented 5 years ago

Fixed the wording and also found another typo.

poeschlr commented 5 years ago

Thanks. Lets see how this goes down if we let it loose to the wild. (I suspect we will find issues as this is a quite complex addition but i assume it to work for the most part.)