Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Exporting DRC Results to Original .gds File

I've been running a simple DRC on a .gds file and right now the output is exported as a new .gds file:

source("./SingleDie.gds")
target("./output.gds")
lyr1 = input(3)
lyr1.merged().space(2.um).polygons().merged().output(902, 0)

Is there an easy way to send the results back into the original file (SingleDie.gds) as a new layer rather than generating a new .gds file?

Comments

  • You're running the script in batch mode, are you?

    I assume you don't want to overwrite the original file (this is bad style IMHO), but you want to add a layer to the original file rather than producing new layers only.

    There is a trick to do this: Without "target" layers are sent to the source layout in "output". You can then use "source.layout.write("...")" to write the enhanced layout to any file you want.

    Like this:

    source("SingleDie.gds")
    
    lyr1 = input(3)
    lyr1.merged().space(2.um).polygons().merged().output(902, 0)
    
    source.layout.write("output.gds")
    

    BTW: you should not need "merged()" before "space" ("space" should imply this). Have you found a reason to use the first "merged"?

    Matthias

  • That worked perfectly! Thank yo so much for your prompt and helpful answer! I knew there had to be a simple solution.

    Well, I didn't write that code for the DRC myself and it appears to work just fine without merging before the DRC so looks like it's not needed.

  • Question - if running interactive, how would the output command differ? Thinking that the "source" command up top would be implicit (present view / "panel") and so maybe the output command doesn't want to refer to that; maybe just

    layout.write("output.gds") ?

    Now I would like to know about file path syntax, for both Windows and Linux, to assert that the output goes somewhere besides ~/Klayout. For example

    C:\Desktop\klayout\DRC_Test1

    and

    /mnt/Data/projects/klayout/DRC_Test1

    Like, are quotes enough to make Windows backslashes digestible, or does each backslash need to be escaped, etc.?

    I haven't been able to find, so probably haven't gotten my script-dabbling to produce an output (having not much luck doping out the debug operation or what its complaints mean. That there would probably be a big HowTo help... an "error bestiary" often being more useful than pages of regExp without real examples.

  • Hi Jim,

    please see my comments of the previous post too ... I'm digging through the recent bunch of posts (somewhat made people post all their questions right before Halloween - is this supposed to be scary?).

    The syntax in general is Ruby, so you have to use double backslash for a single one. But forward slashes should work too. Anyway my last comment mentions a way to use a computed path without the need to put in a specific one.

    There are many Ruby tutorials out there: for the string literal syntax for example you can take a look at: https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals. For details about the File class used for the computed paths see: https://www.tutorialspoint.com/ruby/ruby_file_methods.htm

    Matthias

Sign In or Register to comment.