Using Python script, how to delete all shapes in a layer without deleting text

edited May 2023 in Python scripting

I tried these two: layout.clear_layer(idx) and cell.clear(layer).

Both of these commands remove everything in a layer, including text.

Edit: Sorry I posted this here by mistake. I am sure if I can delete this post...

Comments

  • No worries, I moved the discussion.

    By coincidence I just implemented a "clear" version that takes a parameter to select which shape types to clear. But that will have to wait until the next minor release.

    Until then there is a shape-selecting version of "Shapes.insert" which can be used:

    for cell in layout.each_cell():
      texts_only = pya.Shapes()
      texts_only.insert(cell.shapes(layer), pya.Shapes.STexts)
      cell.shapes(layer).assign(texts_only)
    

    Matthias

Sign In or Register to comment.