agg-kicad icon indicating copy to clipboard operation
agg-kicad copied to clipboard

sexp not behaving well

Open cchamilt opened this issue 9 years ago • 7 comments

Traceback (most recent call last):
  File "agg-kicad/scripts/stickerbom.py", line 454, in <module>
    main(xmlpath, pdfpath)
  File "agg-kicad/scripts/stickerbom.py", line 429, in main
    pcb = PCB(sexp.parse(f.read()))
  File "agg-kicad/scripts/stickerbom.py", line 185, in __init__
    self._parse(board)
  File "agg-kicad/scripts/stickerbom.py", line 296, in _parse
    self.modules.append(Module(module))
  File "agg-kicad/scripts/stickerbom.py", line 47, in __init__
    self._parse(mod)
  File "agg-kicad/scripts/stickerbom.py", line 126, in _parse
    self._parse_pad(pad)
  File "agg-kicad/scripts/stickerbom.py", line 151, in _parse_pad
    layers = sexp.find(pad, "layers")[1]
IndexError: list index out of range

When I wrap sexp.find(pad, "layers") usage with a len check, I get a blank 11 page pdf.

cchamilt avatar Mar 10 '16 16:03 cchamilt

Do you have an example .kicad_pcb file that triggers this behaviour?

adamgreig avatar Mar 10 '16 17:03 adamgreig

For this project it would require an NDA as the design isn't mine to share. Would that be OK?

cchamilt avatar Mar 11 '16 04:03 cchamilt

That is OK if necessary, though if you can isolate what's causing the problem perhaps that would be easier. Could you try adding print(pad) to the top of _parse_pad and see what the output is? It looks like probably one of the pads in your board does not have any layers which is a bit unusual so might be a parsing issue.

adamgreig avatar Mar 12 '16 18:03 adamgreig

Ah, OK. I would guess there are some old patterns with through-holes that were set to no layers instead of npth. I'll add the print and review them. Hopefully that is the fix.

cchamilt avatar Mar 12 '16 19:03 cchamilt

I went through and located the bad npth. So everything has layers and the script finishes, but still seems that the pdf is blank. I'll get you a copy of the NDA asap.

cchamilt avatar Mar 13 '16 09:03 cchamilt

Okay, thanks. Crashing with no layers is obviously still a bug but good to know that was the cause of the exception.

Are you using Python 2 and if so could you try with Python 3? Should work with both but is the root of another pdf rendering bug I'm chasing down.

adamgreig avatar Mar 13 '16 09:03 adamgreig

Yeah, I can confirm it doesn't render in either version of python.

cchamilt avatar Mar 19 '16 01:03 cchamilt