Is there any reason this script might not work anymore? When I right click on my top cell, click "Replace Cells With Others", and choose the library, the library gets imported as a new top cell. The cells in the original layout have not been replaced. Instead, the library cells with the same name get the $1 as if I just tried to import the library GDS.


  • edited June 2019

    Hi NMF,

    I have not tried to debug this issue yet - the script is pretty old already. Are you using the version from


  • Hi Matthias,
    I'm not 100% sure I was using that version, but I tried that one and got the same result.

    Not a big deal, I found a solution using the gds_cellreplace.replaceCells function from Nazca.

    Not to derail - but is it possible to use other GDS/Python libraries from within KLayout (gdsCAD, gdspy, nazca)?

  • Hi Nick,

    Basically you can use external Python modules, but on Windows they need to be binary compatible, which isn't straightforward. Linux usually isn't an issue.


  • I'm trying to understand the issue with replace_cells.lym, but I failed to reproduce it. I have attached a simple testcase with two layouts:

    • top.gds contains a TOP cell with two subcells A and B, each containing a text
    • lib.gds contains two replacement cells B and C with a different text

    When I load top.gds and use "Replace cells with others", A stays the same, B is replaced and C appears as a new top cell. That's what replace_cells.lym is supposed to do.



  • I figured it out: the library can't have a top cell. All the library cells need to be top level - they can't be in their own "top" or "library" top cell. The description "even with their own hierarchy" made me think that didn't matter, but now I see that means there can be hierarchy BELOW the library cells. When I put all the library cells at the top level together it works. Thanks!

    (Knew I was missing something simple!)

  • Very good :) I hope the example helped.



Sign In or Register to comment.