Merge layer with Ruby script

edited June 2013 in Ruby Scripting
Hi,
There is a merge operation in the menu: Edit -> Layer -> Merge
I want to do the same thing with Ruby script. I have a layer, with some boxes/polygons, I know the layer index and I want to merge all the shapes.

What is the right way to do it?

thank you!

Comments

  • edited November -1

    Hi Sveta,

    the full functionality of the merge function is not available yet (I am working on it, but I cannot provide a timeframe).

    A simple version of the merge function can be implemented by simply loading both layouts into one RBA::Layout object:

    ly = RBA::Layout::new
    ly.read(filename1)
    ly.read(filename2)
    

    Please note that this will merge all cells with the same name into the same cell. So if you have two layouts, both with top cell TOP and no other hierarchy, the resulting layout will have one cell called TOP and all shapes merged into that cell.

    Regards,

    Matthias

  • edited November -1

    Has already a function to do such a thing ?

  • edited November -1

    Cell#copy_tree and relatives are your friend.

    Matthias

  • edited November -1

    Matthias,

    I'm back and trying to understand how I merge two layers.. I search for Cell#copy_tree but I don't understand how use it.
    Can you give me a exemple ?
    Why I have to use cells if I want to merge layers ?

  • edited November -1

    Hi,

    maybe you'll need to start right at the beginning. Here is a good starting point: http://www.klayout.de/doc/programming/index.html.

    To use Cell#copy_tree, you'll need to create two layouts, load the two files into these two layouts and then copy over the source cell into the target cell using Cell#copy_tree.

    You can find an example here: http://klayout.de/forum/comments.php?DiscussionID=537&Focus=2279#Comment_2279.

    Matthias

Sign In or Register to comment.