It looks like you're new here. If you want to get involved, click one of these buttons!
This is a support request that I received recently:
I would like to know if it is possible with klayout through a script to
give it 2 or more gds files and create a new one where by ex. in the 1st
gds we are replacing a cell named "trial1" and his hierarchy with the cell
"trial1" with his hierarchy which is present in one of the other gds files
There is actually at least one solution provided that both GDS files have the same database unit. This one is even working without a script.
The solution is: you can simply copy cells including the sub-hierarchy from one layout to another.
To do so, open KLayout in Edit mode and load both layouts (i.e. "File" menu, "Open in new panel"). Then select the "trial1" cell from the cell tree of the second layout and choose "Copy" from the cell tree's context menu or the "Edit menu". Then go to the first layout and choose "Paste" from the cell tree's context menu. This copy & paste operation selects the whole cell plus any sub cells.
A new cell "trial1$1" will appear in the cell tree plus probably a lot more that you don't see because they are part of the copied cell's hierarchy. To avoid name clashes, these subcells may also have been renamed by appending a unique index of the form "$n".
To switch the to this new cell, select the instance of the original cell (choose a hierarchy level where the ROM cell is shown as a box and click on that box), open the properties dialog (i.e. "Edit/Properties") and type in the new cell name. Choose "Apply" to actually switch the cell.
The old "trial1" cell will appear as a new top cell since it is no longer
referenced. If that is a problem, simply delete that cell.
A script solution is also possible, but this would be somewhat slow since the script framework is currently not supporting whole-cell operations.