heitzmann / gdstk

Gdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.
https://heitzmann.github.io/gdstk/
Boost Software License 1.0
324 stars 78 forks source link

Polygonal coordinate problem #223

Closed SouthChinaHuihuisauce closed 6 months ago

SouthChinaHuihuisauce commented 7 months ago

Hello dear author, I encountered a problem when using gdstk to draw polygons. When obtaining coordinates, it seems that gdstk will also output the defined polygon coordinates. I would like to know how to close it?

CODE RES

heitzmann commented 7 months ago

You seem to bee looping over all cells in the library. You probably want to select 1 cell and only display polygons from that cell. In the KLayout screenshot you are only displaying polygons from the NMOS cell (the get_polygons function will get polygons from references, so there's no need to loop over cells.)

SouthChinaHuihuisauce commented 7 months ago

You seem to bee looping over all cells in the library. You probably want to select 1 cell and only display polygons from that cell. In the KLayout screenshot you are only displaying polygons from the NMOS cell (the get_polygons function will get polygons from references, so there's no need to loop over cells.)

Thank you for your reply. I have resolved the issue through your reply. Thank you

SouthChinaHuihuisauce commented 7 months ago

@heitzmann Hello, I would like to ask if there is any GDSTK that can output cell information, similar to Klayout. 2023-12-18_090943

SouthChinaHuihuisauce commented 7 months ago

@heitzmann Dear author, hello. I have output all cell names, but I don't know how to distinguish the relationship between calls gdstk

heitzmann commented 6 months ago

@SouthChinaHuihuisauce you have to look into the references array for each cell. The cells form a DAG structure that can be traversed if you go through each of the references.

SouthChinaHuihuisauce commented 6 months ago

@heitzmann Dear author, first of all, thank you for your reply. I have tried the references you mentioned, but I am not familiar with gdstk and gds files. Can you give me an example?

coding log

heitzmann commented 6 months ago

You'll probably want to write this as a recursive function. Something like this (in python for brevity):

def print_references(cell, indent=""):
    print(indent + "- " + cell.name)
    for reference in cell.references:
        print_references(reference, "    " + indent)
SouthChinaHuihuisauce commented 6 months ago

@heitzmann Thank you very much for your sample code. We have found it