XOR between 2 gds using Python with different layer mapping for gds files.

How to import layer mapping files from Technology Manager, then load 1 gds, import another layer mapping file, load a second gds and then make XOR all using Python through pya.



  • edited March 20

    You can get all of this for free when you use the "strmxor" buddy tool.

    This is a separate binary that comes with KLayout. On Linux, just install the package and run "strmxor".

    strmxor --help-all

    will give you all the options. On Windows, the same binaries are installed along "klayout_app.exe". They come as console applications, so you can embed them into your own scripts.

    This should do the job:

    strmxor --a-layer-map-file a.map --b-layer-map-file b.map a.gds b.gds xor.gds

    For the pya solution you need to be much more specific about your actual requirements - specifically how XOR needs to be done - and the solution can become pretty complex.


  • Hi Matthias,

    Thanks for your response.
    I'm going to enumerate the issues I had one by one.
    1. On my work computer, I can see all the binaries but only klayout call is working, the buddy command do not. It popped up a loading shared libraries error.
    2. I wanted to install klayout alone but I'm facing issues too, it started to install but failed at the end. Cannot find -lpython3.6m error and when I tried to upgrade python it failed too.
    3. When running Python by command line, it's not taking.


  • I need some more details.

    What OS are you on and how did you install KLayout?

    If KLayout runs, the buddy tools should run too as they sit in the same directory and share the same shared objects.


  • edited May 30

    Hi Matthias, what is the format of the layer mapping file in a-layer-map-file? I used an lyp file but it gave me this error:
    ERROR: Error at argument #2 (option --a-layer-map-file=map): Expected end of text here: <?xml ver .. in line 1)

    Or perhaps, is there some script that converts the lyp format to this a-layer-map-file?

  • Thanks, this link is useful!

Sign In or Register to comment.