How to convert gds to dxf (using convert options. Set layerName, layer Color...)

Hello. i'm a beginner
I would like to know the following two things

  1. how to convert gds to dxf through a script
    (I Know this is a duplicate question but, i want to know a brief example)

  2. how to set convert options
    (gds layerNumber → dxf layerName, Color)

I really need help..

Comments

  • edited July 2024

    1. how to convert gds to dxf through a script
    (I Know this is a duplicate question but, i want to know a brief example)

    See, for example, https://www.klayout.de/forum/discussion/2514.
    The attached ZIP file contains modified versions of Python scripts for the above post.
    The scripts assume that a CAD tool interprets the coordinates in the DXF as millimeters.
    Try

    $ ./f2543.py -i ringo.gds -o
    

    2. how to set convert options
    (gds layerNumber → dxf layerName, Color)

    The DXF writer does not provide many optional parameters, as shown in the figure below.
    The most important one would be dxf_polygon_mode.

    As far as I know, the KLayout's DXF writer does not provide explicit layer naming and color mapping today.
    The layer name will be L{xxx}D{yyy}, where {xxx} is the layer number and {yyy} is the datatype number in the GDS, respectively.
    So you can use a text editor to find the layer names and replace them if necessary.

    ringo-DXF ringo-fruits

    Similarly, colors in DXF are automatically mapped to AutoCAD color indexes.
    To set/change colors, use a DXF CAD tool, not KLayout.

    I've done a little research on colors by dumping and filtering the `ringo.gds' file.

    As you can see in the image above, the first layer is L/D=5/0, which is given index=1.
    The second L/D=1001/0 is mapped to index=2. The third L/D=8/0 is mapped to index=3, and so on.
    The DXF color indexes on the left (12, 5, 8, 7, ...) were found by manually searching the DXF file.

    According to the table below, index = (1,2,3) corresponds to color = (red, yellow, green), which corresponds to the middle part (QCad screenshot) of the image above.

  • edited July 2024

    Cont.

    3. Loading a DXF file

    In contrast, the LoadLayoutOptions class provides many options for reading DXF files.

    The attached ZIP file contains the f2543-rev.py script, which reverse converts ringo-fruits.dxf to ringo-fruits.oas, where layer mapping is performed on the fly.
    However, changing/setting the layer colors has to be done manually. Or write (add) code to automatically generate the *.lyp XML file.

Sign In or Register to comment.