Failed to Parse Gerber file

Issue #261 new
FlatCold created an issue

Hi, I am new to this, so there is a lot of things I don't know yet. I am getting and error message about parsing gerber file, LED.GTL. File is attached. LED.GTL is the top layer gerber file generated by Altium Designer v18.1.7 and I am using FlatCAM 8.5 (2016/07) on Windows 10 Pro 64bit. Error message is [error] Failed to parse file: D:/Projects/3D Printer/Projects/Upgrade/Light/MIC3202/Project Outputs for LED/LED.GTL. Line 53: G37* I noticed if I delete Line 26 to Line 51, it will parse but it is missing some geometry. Bottom layer LED.GBL (not attached) parse just fine and it has way more geometries than LED.GTL.

Issues similar to this are https://bitbucket.org/jpcgt/flatcam/issues/174/failed-to-parse-file https://muut.com/i/flatcam/usage:failed-to-parse-file but I am not certain how the solutions applies to this case. One of the solutions mentioned "debug messages when running the development version". Is the development version available for Windows or is there any way for Windows version to show debug message?

Comments (4)

  1. Marius Stanciu

    Furthermore, your full error is (ignore the filepath, obviously is different in my case):

    [error] Failed to parse file: C:/Users/FORCE/Desktop/LED.GTL. ('Line 53: G37*', "TypeError('must be real number, not NoneType',)")

    When running the development version it can be seen that the file parsing is having error on this line on the parse_lines() method from camlib.py:

    region = Polygon(path)

    Printing the path variable I get this:

    [[2.7165, None], [2.6260000000000003, None], [2.6199000000000003, 0.02], [2.6234, 0.0223], [2.6402, 0.037000000000000005], [2.6548000000000003, 0.0538], [2.6672000000000002, 0.0723], [2.6771000000000003, 0.09230000000000001], [2.6842, 0.1134], [2.6886, 0.13520000000000001], [2.6892, 0.14500000000000002], [2.3501000000000003, 0.14500000000000002], [2.3508, 0.13520000000000001], [2.3551, 0.1134], [2.3623000000000003, 0.09230000000000001], [2.3721, 0.0723], [2.3845, 0.0538], [2.3992, 0.037000000000000005], [2.416, 0.0223], [2.4194, 0.02], [2.4134, 0.0], [0.0, 0.0], [0.0, 1.063], [2.7165, 1.063], [2.7165, 0.0]]

    See the None in Y coords for the first 2 elements of the list? Those are giving the error.

    After that it was simple to look in the Gerber file and see that lines 27 and 28 for some reason don't have Y coordinates (and there is no preceding Y coordinate so FlatCAM can use):

    X027165D02*

    X026260D01*

    That why the file is not parsed. For some reason AD18 is not putting there Y coords. If I remove those 2 lines I get the picture from attachement (I used my own fork of FlatCAM, that's why the interface is a bit different).

    file_parsing.JPG

  2. Marius Stanciu

    If I change lines 27 and 28 to:

    X027165Y000000D02*

    X026260Y000000D01*

    (meaning I add a Y000000 coord), the file is loaded OK.

    Other Gerber viewer programs may ignore those lines.

  3. Marius Stanciu

    @FlatCold I've added support for ignoring the incomplete Gerber lines in case that the missing coordinates are not present even in the previous line. You can try it in my FlatCAM fork and if OK then I may make a pull request here.

    It will help if you can add the PcbDoc here so I can see why Altium generated imcompleted Gerber lines (might be a design error or a bug: if it's a bug I might file it to Altium BugCrunch).

  4. Log in to comment