gdstk icon indicating copy to clipboard operation
gdstk copied to clipboard

Feature Request: layers_and_datatypes for Cell object

Open nmz787-intel opened this issue 5 months ago • 3 comments

I would like to know if there is a faster way to get a list of layer:datatype tuples like: https://heitzmann.github.io/gdstk/library/gdstk.Library.html#gdstk.Library.layers_and_datatypes

except on a particular Cell. Currently it seem I have no other option than to iterate over all get_polygons

nmz787-intel avatar Jul 16 '25 22:07 nmz787-intel

Not really… this is a fundamental issue with the architecture of gdstk (storing layer information in polygons). The best we can do is write the required loop as a C function instead of in python.

heitzmann avatar Jul 19 '25 14:07 heitzmann

that would certainly be an improvement, and would reflect the usage pattern for the Library object

nmz787-intel avatar Jul 30 '25 18:07 nmz787-intel

The internal data structure of gdstk can be thought of as a very thin wrapper around GDSII/OASIS formats, with very few opinionated additions. And in GDSII, layer and datatype are simply properties of a polygon. So under the hood, Library.layers_and_datatypes() simply loops over each cell and each polygon of that cell anyway. Constructing any additional data structures to support Cell.layers_and_datatypes(), whether by gdstk or by yourself, is orthogonal to GDSII/OASIS parsing.

WesYu avatar Sep 16 '25 08:09 WesYu