I want to know code for Parse Gerber file (RS-274? )

Issue #514 closed
KiNG FPGA created an issue

Hello, I am Altium User. I find that the FlatCAM open successfully gerber file made by Altium.

I want to know where gerber file is parsed and draw. I am new in Python. I am fluent with C++

could you let me know me specific file and function name for parse gerber file ?


Comments (5)

  1. Marius Stanciu

    It depends on what version of FlatCAM you are interested in: the old one (version 8.5 and Master branch) or the Beta branch.

  2. KiNG FPGA reporter

    Hello, I am work now Master branch now.

    is it possible to unit test for parse gerber?

    it is too much complex to me as it has QT graphing library

  3. Marius Stanciu


    I don’t work on the master branch, I am only in charge with the Beta branch so I can’t help you on that.
    But I can give you some hints.

    For Master branch:
    - Gerber files actual parsing is done in the camlib.py file, Gerber class (who inherits from Geometry class), through methods: parse_file() and parse_lines(). The resulting geometry elements (Shapely geometry) is stored in the solid_geometry attribute (it’s a list).
    - plotting Gerber data on canvas is done with plot() method found in the FlatCAMGerber class (who inherits from above mentioned Gerber class). FlatCAMGerber class can be found in the FlatCAMObj.py file. Plotting (drawing) data is done by iterating in the solid_geometry list of Shapely geometry objects (generated by the parse_lines() method) and those are sent to the graphic processing done by the matplotlib methods.

    Best regards,

  4. Log in to comment