Batch boolean operations on GDS

edited August 2012 in General
Hi,

I have scripts to input .CIF and other formats, and stream to .GDS.

Now between the input and output, I'd like to do a boolean operation on layers in the file.

Perhaps more clearly:
1) I have a file named filename.CIF or filename.GDS. It has a single cell named cellname. This cell has a rectangle on layer 1 and an overlapping circle on layer 2.
2) I open it using a ruby script
3) Now I want to do Add, Subtract, And, Or, Xor, etc to the two layers 1 and 2 on cellname. Knowing how to do Grow/Shrink would be nice too.
4) Finally, I stream to GDS.

It's step 3 I'm asking about -- how to write ruby script to do this in batch mode.

Thanks
David

Comments

  • edited September 2012

    Hi David,

    this is a job for the layer processing framework http://www.klayout.de/useful_scripts.html#layer_proc.rbm. The ruby module itself contains some documentation about how to write processing scripts.

    Although it is intended as an interactive functionality, you can use it in batch mode with some additional scripting.

    Once you have installed the layer_proc.rbm file (i.e. by copying it to the installation path of your klayout executable), you can use the layer processing framework in batch mode using this batch script:

    # Run a layer_proc script in batch mode.
    # Requires that layer_proc.rbm is installed.
    # 
    # Provided this script is saved to lp_batch.rb, run it like this:
    #
    #   klayout -rd input=input.gds -rd lp_file=script.lp -rd output=output.gds -r lp_batch.rb -z
    #
    # Replace input.gds by the name of your input file (can be any other
    # format supported by KLayout), script.lp by you layer processing script
    # and output.gds by the name of the output file (can be any other format
    # as well).
    
    ly = RBA::Layout.new
    ly.read($input)
    
    lp_text = nil
    File.open($lp_file) do |file|
      lp_text = file.read
    end
    
    top_cell = nil
    ly.each_top_cell do |top| 
      top_cell = ly.cell(top)
      break 
    end
    
    lp = LayerProcessor.new(ly, top_cell, nil)
    lp.run(lp_text)
    
    ly.write($output)
    

    Please note, that you cannot use the "report" statement in your layer processing script.

    Regards,

    Matthias

Sign In or Register to comment.