How to only keep layout in fixed area?

edited September 26 in Layout

Hi,
@Matthias
Do you know how to get layout in fixed area and save in another gds file?

When patterns are connected to each other, select and save are not complete, it will miss patterns.
I can only find a way not very straight to do this.
I can draw a pattern signaling which area I want to keep. Then, using boolean "and" function to get the overlaping area.
But when there are too many layers, it is cumbersome to write all those layers. Do there have some function giving all the layers in a layout?

For example, how to keep figures only in black box?

Best regards!
Weiling

Comments

  • Hello,

    You can use the "Clip" tool (Edit > Utilities > Clip Tool).

    https://www.klayout.de/doc-qt5/manual/clip.html#k_1

    Cheers,

    Tomas

  • I recommend the clipping tool, as well, the hierarchy aspect is great!

    As for going through each layer - here's a DRC example:

    cv = RBA::CellView::active
    inputDir = File.dirname(cv.filename)
    target("#{inputDir}\\out_clip.gds", "OUT_CLIP_TOP")    #gds where the output will put data
    
    deep    #usually faster but you can remove to perform a flat operation
    clip_lay = input(1,0)    #layer you used for grabbing overlaps
    
    #Go through each layer in current view
    layers.each {|lay|
        overlap_lay = clip_lay.and(input(lay)) #can even change 'and' to 'overlapping' if you want to grab all touching shapes
        overlap_lay.output(lay)
    }
    

    If you want to go through each layer in ruby:

    view = RBA::LayoutView::current
    view.each_layer { |lay|
    ...
    }
    

    Hope this helps

  • @tomas2004 ,

    Thank you for your respond. It's the easiest way to do this when the cliped areas are uniform areas in most cases.
    But when clipped area are nonregular areas, those method seems not suitable.
    Wish to include nonregular polygons into this function.

    Best regards!
    Weiling

  • edited September 29

    @blueman_44,

    Thanks a lot for your respond.
    I tried this method, but I don't know how to deal with this two sentences.

    inputDir = File.dirname(cv.filename)
    target("#{inputDir}\\out_clip.gds", "OUT_CLIP_TOP")    #gds where the output will put data
    

    eg: I have a gds, whose complete dir is /nfs/workspace/abc.gds, and its top name is test.
    How do I need to fill in this two sentences? I am not familar with those rules, or do you have some pages about this to refer to?

    Lastly, I change those two sentences into one sentence, like this:
    target("\\nfs\\workspace\\chingriver\\abc.gds", "test") #gds where the output will put data

    Except this, I only change one sentence:
    clip_lay = input(10000,0) #layer you used for grabbing overlaps
    as the clipped area is in 10000/0 layer
    It seems it does operate, but I got nothing change in the gds.

    What had happen?
    Could you give me some suggestion?

    Best regards!
    Weiling

  • Those two lines are just creating a new gds in the same folder as your current gds (that way you don't overwrite data). You can write them however you see fit, but make sure they don't match any existing gds files.
    Here is the target drc method documentation: https://www.klayout.de/doc-qt5/about/drc_ref_global.html#k_124

    Changing the clip_lay should work... are you trying to write to the same gds file? You can also make breakpoints in your drc

Sign In or Register to comment.