Pcbnew can't open P-CAD ASCII files

Bug #1545668 reported by Robin Whittle on 2016-02-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Undecided
Dick Hollenbeck

Bug Description

Application: pcbnew
Version: (2016-02-14 BZR 6556, Git aa6beaa)-product release build
wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1009,GCC 5.2.0,wx containers,compatible with 2.8)
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Boost version: 1.57.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

The latest nightly build (as above) generates an error message when opening even a simple P-CAD ASCII file. So does version 4.0.1 stable. However, version 2013-07-07 works fine.

I discovered this with complex real design files, each of which were exported from the 30 day trial version of Altium 16.0.6 (build 282) after importing a Protel 99 SE file. The first attachment below is a file made in Altium - with just a single DIP 16 footprint and no tracks. I exported this as "P-CAD ASCII". Then I attempted to open this with Pcbnew, using File > Open and selecting in the bottom right box: "P-CAD 200x ASCII PCB files (*.pcb)". The error message from the nightly is:

- - -

Error loading board.
PARSE_ERROR: Expecting "(" in input/source
'C:\PCB\PCB1-from-Altium-16-0-exported-as-P-CAD-ASCII'
line 1 offset 1
from dsnlexer.cpp Expecting() : line 361

- - -

The message from 4.0.1 is similar. With Kicad 2013-07-07 there is no error and the design is read in without any problems. A small PCB file with multiple footprints and tracks on both sides, though it has no legends, is:

http://www.firstpr.com.au/temp/kicad-bugs/TX16W-memory-board-1992-from-Altium-16-0-exported-as-P-CAD-ASCII.PCB

Related branches

Tomasz Wlostowski (twlostow) wrote :

Hi Robin,

Could you try removing the first line:

ACCEL_ASCII "D:\PCB\non-Kicad\Autotrax-to-Kicad\3-Autotrax-PCBs-PCAD-ASCII-and-Eagle-format\TX16W-G.PCB"

from the PCAD file and try importing it again?

Tom

Robin Whittle (rw-p) wrote :

Actually, the TX16W file does have component legends etc. as you can see by this file which results from importing it into Eagle 7.5.0: http://www.firstpr.com.au/temp/kicad-bugs/TX16W-memory-board-1992-from-Altium-16-0-exported-as-P-CAD-ASCII.PCB.brd , which, when opened with Kicad 4.0.1 shows the full design: http://www.firstpr.com.au/temp/kicad-bugs/TX16W-memory-board-1992-from-Altium-16-0-exported-as-P-CAD-ASCII.PCB.brd.kicad_pcb .

Its just that Kicad 2013-07-07 does not show them, due to the value being written to the reference, which is set to invisible, and nothing being written to the value. Nor does the saved Kicad file contain the text of the legends on copper or overlay layers. So the old import code did not work properly. This bug report is solely for the ability to read the file at all.

Dick Hollenbeck (dickelbeck) wrote :

The problem with loading this *.pcb file is fixed by attached patch. Please commit it somebody.

If the board still does not look correct, then that is a larger issue with the plugin not related to this
simple "file header test" fix.

Dick

Changed in kicad:
assignee: nobody → Dick Hollenbeck (dickelbeck)
status: New → Fix Released
Robin Whittle (rw-p) wrote :

Tom, I didn't see your message earlier. I tried removing the first line and got an error message from pcb_parser.cpp "unknown token "asciiheader"". Likewise when I deleted everything before "(library".
I got various errors with other attempts at editing the file which I won't list here, because it would be more meaningful for someone to try the same things with the latest version of the program running under a debugger. I have not yet been able to compile Kicad under Linux, and I don't want to try it for Windows. (I do want to use it under Windows for various reasons to do with monitors, printers and my Logitech trackball, so Linux compilation would only be for debugging.)

Dick, I noticed your patch is now part of what, to the best of my knowledge, is the main development branch:

https://github.com/KiCad/kicad-source-mirror/commit/78d0cfc1a4c131b0973f49ec1d2620d04635b69e#diff-d9bb9ec4a9d3efca2bfd0f7d502d008f

https://github.com/KiCad/kicad-source-mirror/blob/master/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp

I downloaded the latest nightly which presumably has this patch: kicad-product-r6566.c2fd462-x86_64.exe

With the file I attached to this bug, the error message was from dsnlexer.cpp "Expecting "(" in input/source". I tried various edits of the file and got various error messages.

The two example files I provided seem to be valid in terms of being read OK by Altium (which produced them), by Eagle, and by Kicad 2013-07-07. I think that what is going wrong would be pretty obvious under a debugger.

As best I know this patch did not fix this problem, so I changed the status of this bug report from "Fixed Released" to "In progress".

Thanks for Kicad!

 - Robin

Changed in kicad:
status: Fix Released → In Progress

The bug is fixed.
Your issue is an other issue: your file has the extension .PCB
The expected extension is .pcb
It make no difference on Windows for the filename, but creates this issue because the file is not recognized as PCAD file by Pcbnew.

I fixed this case sensitive issue in rev 6567.

Changed in kicad:
status: In Progress → Fix Committed
Robin Whittle (rw-p) wrote :

Hi Jean-Pierre,

Thanks very much for this. With 4.0.1 on Win7 64 bit, changing the filename extension to ".pcb" enabled me to read the files. I perceive some problems with results, which are not part of this bug, but which I mention as guidance for people using this workaround: reference and value fields are set to invisible; mirrored and/or rotated text is placed incorrectly.

The nightly (kicad-product-r6566.c2fd462-x86_64.exe - currently the latest) seems to produce the same results. I am not sure which files you changed to fix the Windows case sensitivity. I guess that nightlies which include this fix will also produce the same results when the file name extension is ".PCB".

Robin

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers