Can Klayout read Gerber files in .zip format? (Python script)

edited May 31 in Python scripting

Could Klayout read Gerber files in .zip format and convert to file .PNG image (Python script)? Many thanks

Comments

  • edited May 31

    Hi @hieund,

    Basically, yes. But KLayout is a tool made for GDS2 files and not for Gerber. The way to go, is to import into KLayout (using GDS2 layers) and then create a PNG from that.

    So that takes some scripting. Here is a sketch:

    1. Unpack the .zip archive
    2. Create a PCB project - this is a XML file listing the artwork files and which layer (GDS notation) they will be mapped on. Store that in a file - e.g "project.pcb"
    3. Provide display styles for these layers in Form of a .lyp file: this can be generated interactively in KLayout and saved as .lyp
    4. Import the Gerber project file into a layout view in KLayout together with the .lyp, and using a specific configuration to disable grid lines, setting background color and such
    5. Export the view's image as PNG

    A minimum example of a PCB project is this:

    <?xml version="1.0" encoding="utf-8"?>
    <pcb-project>
     <free-layer-mapping>true</free-layer-mapping>
     <layout-layers>  <!-- a list of GDS layers to map to (first one is index 0, second index 1 etc.) -->
      <layout-layer>1/0</layout-layer>
     </layout-layers>
     <free-files>
      <free-file>
       <filename>2-13-1_Two_square_boxes.gbr</filename>
       <layout-layers>
        <index>0</index>   <!-- lists the layers the file will be mapped on, 0 = first layer (see above) -->
       </layout-layers>
      </free-file>
     </free-files>
     <merge-flag>false</merge-flag>
     <dbu>0.001</dbu>
     <cell-name>PCB</cell-name>
    </pcb-project>
    

    Matthias

  • Thanks a lot @Matthias

Sign In or Register to comment.