Home Forums Nazca get layers used in a layout

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6097
    bastien
    Member

    Hi,

    I’m trying to get all the layers and datatype used in a layout (made using nazca or loaded from a gds). I tried (see example below) to use get_layers() but it yields KeyError: “[‘nazca_name’] not in index”.
    How can I get a list/dict of all the layers used?

    nd.clear_layout()
    with nd.Cell() as cell:
        r = nd.geometries.box(length=2, width=1)
        nd.Polygon(points=r, layer=1).put()
        cell.put()
    nd.get_layers()
    nd.export_plt()
    #6099
    Ronald
    Keymaster

    Dear Bastien,

    All layers are stored in a Pandas DataFrame in the cfg module. You can access it as
    df = nd.cfg.layer_table

    The method nd.get_layers() simply gets you the same DataFrame with a column filter added, but a column name has been changed into “layer_name”, hence the error. Will fix that and put a test on it.

    Alternatively to print the layers to stdout you can use
    nd.show_layers()

    Ronald

    #6100
    bastien
    Member

    Thank you Ronald!

    df = nd.cfg.layer_table

    works perfectly for my use case

    Bastien

    • This reply was modified 3 months, 2 weeks ago by bastien.
    • This reply was modified 3 months, 2 weeks ago by bastien.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.