PCBnew max file size

I have run into an error where pcbnew cannot load a file of a large size.

IO_ERROR: Maximum line length exceeded

The file is over 85K lines long. I have tried to traces this error but cant find where the max file size is actually set.

Notice that the error message doesn’t mention file size, but line length.
What size is the longest line in the file?

If you’re using Linux, try this command, otherwise use Notepad :
wc -L file.pcbnew

ahhh. 177893. Which is a license text file that snuck in I think. Ill trim those off and see what I get.

I get this following error, IO MAX Length exceeded. C:/Jenkins/workspace/windows-kicad-msys2-stable/src/kicad-4.0.1/common/richio.cpp : Readline() : line 241 - any ideas on how to get my pcb file to open?

@destroyer

  • what are you doing when you get this error?
  • did it work before?
  • what did you change between then and now?
  • we can assume windows and kicad version but would be nice to have more detailed info in case someone knows if that’s a os/version specific behavior…

Windows 10 - KiCad 4.0.1 stable

Last night I exported gerber files, dxf, and drl files. This morning i opened up the project and when i tried to open the pcb file this was the error i got.

I had a problem with this before. Its not the size of the file its the
length of the line.

KiCad can only handle a line that is so long (not sure what the actual
length is). Chances are you are importing something from a file that was
not originally KiCad. There are often embedded web links or product
information that is all put on one line and it is to much.

To fix the issue you have to go through the file manually with gedit or
some other text editor and make long lines shorter. You can just delete
these lines but you risk damaging detail in the files. The files are very
readable so you should be able to see that you are not deleting critical
information. I think this error is most commonly seen when importing from
altium.

This error can occur multiple times in a file. I had it occur over 1000
times in mine when importing from altium. A good python script will be
handy in fixing large file.

What @Reiner_Schmidt says… open the .kicad_pcb file in a text editor (notepad++ for example) and go hunting for very long lines that contain stuff that is ‘useless’…

PS: make a copy of the file before you modify it :wink:

when i open the file is has a bunch of NULL squares in it. it must have been corrupted.

check the .kicad_pcb-bak file… pray to < deity of your choice > you didn’t save the broken version over that one as well and that the automatic backup is pretty recent.
Best advice: make a backup copy of that whole project folder immediately before you do anything else.

the .bak file is still readable / looks ok. should i just coopy and past that into the .pcb file?

if you got a backup of everything… sure.
Cause if that one is older than a couple of hours you might still scream and I don’t want to be responsible for that. :nerd:

dn’t worry its all good! thanks for your help1!!

1 Like

Which leads to the obvious questions
What is the maximum line length supported ?
Why does the error message not say what that limit is, and what the found length is ?

Also, I usually see a useful source file name and line number for any import errors, was that trimmed in the post, or not given ?

viz an ideal error report is something like
Length 1234 exceeds IO MAX Length ( 999) C:/path/Name.kicad_pcb Line 4567
C:\Jenkins/workspace/windows-kicad-msys2-stable/src/kicad-4.0.1/common/richio.cpp : Readline() : line 241

the cpp line no, is useful only if you chase a bug…