gdstk icon indicating copy to clipboard operation
gdstk copied to clipboard

Some repetition patterns are not read correctly

Open svollenweider opened this issue 8 months ago • 1 comments

Dear all,

I encountered an issue when reading a gds made in LayoutEditor. The GDS renders correctly in LayoutEditor and KLayout, but is wrongly read when imported into gdstk.

Attached is a gds to reproduce this issue: minimum_working_example.zip

This is the setting used in LayoutEditor to generate the array: Image

This leads to a Pattern Spacing of 0,0, when read in gdstk

I am using python to read the gds:

import gdstk

def loadGDS(path: str):
    gdslibrary = gdstk.read_gds(path)
    for cell in gdslibrary.cells:
        print(cell.name)
        new_references = []

        for element in cell.references:
            if isinstance(element, gdstk.Reference) and (element.repetition.columns is not None or element.repetition.rows is not None):
                oldrep = element.repetition
                spacing = oldrep.spacing

                if oldrep.spacing == (0, 0):
                    print(f"AREF repetition of cell '{cell.name}' is 0,0")

Is this behaviour a bug or a result of LayoutEditors liberal implementation of the GDS standard?

svollenweider avatar Apr 16 '25 08:04 svollenweider

Related issue: https://github.com/heitzmann/gdstk/issues/293. In your example the array doesn't have reflection or rotation. Therefore gdstk assumes that your "step x" (or column vector) is in the x direction and "step y" (or row vector) is in the y direction, and only takes the x coordnate of step x and y coordinate of step y. This is how you end up with 0 spacing in both directions. This case where the array has no reflection or rotation is also called RepetitionType::Rectangular in gdstk. But if we look at display results from the likes of KLayout, reflection and rotation are individual transformations of the referenced cell, not the matrix. I believe we should always keep both the step x and step y vectors, whatever direction they might be in, a la RepetitionType::Regular, irrespective of whether reflection or rotation is present.

WesYu avatar May 21 '25 08:05 WesYu