Hi, I love the project. Thank you for making it!
I am using it on a KiCad PCB where I've manually added the mounting holes using the "add footprint" command in the PCB editor ("A" shortcut.) The footprint is MountingHole_3.2mm_M3_DIN965
.
When I run turbocase
it crashes claiming that the hole has no property Reference
, which could be true (the KiCad editor says it has a field named "Reference designator"
).
% turbocase project.kicad_pcb case.scad
Traceback (most recent call last):
File ".../env/bin/turbocase", line 8, in <module>
sys.exit(main())
File ".../env/lib/python3.9/site-packages/turbocase/__main__.py", line 64, in main
case = load_pcb(args.pcb, args.layer, args.lid_layer)
File ".../env/lib/python3.9/site-packages/turbocase/kicad.py", line 390, in load_pcb
ref = hole.property['Reference']
KeyError: 'Reference'
I ended up modifying the code to handle this case in a sort of juvenile way:
unknown_holes = 0
for hole in mountingholes:
center = hole['at'][:]
# new code begins here
if 'Reference' not in hole.property:
hole.property['Reference'] = f"HOLE{unknown_holes}"
unknown_holes += 1
# new code ends here
ref = hole.property['Reference']
After making it generate references for each of the unknown refs, it produces a nice case.
My KiCad version is 7.0.9 if that matters, and I can send you the kicad_pcb file via email or a GitHub link if you want to look at it more closely. Thank you again for such a great project!
Oh that's an interesting change in KiCad 8 then, there you get the reference "REF#" set if you add footprints in the board editor.
The reference is not actually used except to add a comment in the final generated OpenSCAD file to know which function call is for which hole. I think it's easier to just set it to
REF#
if there's no reference defined through KiCad in this case.I've pushed a fix for this to git.