Home › Forums › Nazca › export cells into an existing gds › Reply To: export cells into an existing gds
Dear Paul,
There is a special mechanism in Nazca to replace parametric and/or static cells.
In case of static cells the example below shows how you can use on or more GDS library files as a source to replace cells in your original gds by name. It doesn’t matter how many or how deep in the tree those cells are:
import nazca as nd
# File name of gds input.
gdsin = 'example.gds'
# a list of scell (static cell) libraries:
# and a cellmap for each library file: { : }
# where resides in gdsin and in the lib.
scell_libs = {
'scell_lib1.gds': {
'C': 'newC',
# other cell name mappings
},
# other libs and mappings as needed
}
# Replace cells and write output to a new gds file (gdsin will not be changed).
nd.replaceCells(
gdsin=gdsin,
ScellMapping=scell_libs
)
Starting with the following cell structure
A
B
C
D
the replacement C -> newC gives
A
B
newC
D
Although A has different content now, effectively only its references to C have been changed. So, I kept A’s original name.
In contrast, if you replace A -> newA you get
newA
# branches in newA
D
If you replace A by newA the substructure (the tree) of A is irrelevant as it is replaced as a whole; You remove the whole branch behind the cut. Cell newA can be a cell or tree of cells.
If newA would look like
newA
C
then the replacement result A -> newA is
newA
C
D
If newA would look like
newA
newC
then the replacement result is
newA
newC
D
If you have two libraries like
# lib1.gds:
NewA
C
# lib2.gds:
newC
then you would use
gdsin = 'example.gds'
scell_libs = {
'lib1.gds': {'A': 'newA'},
'lib2.gds': {'C': 'newC'}
}
nd.replaceCells(
gdsin=gdsin,
ScellMapping=scell_libs
)
to obtain
newA
newC
D
Note: Since Python 3.7 dictionaries are ordered as a language feature, which is important as replacement is not commutative in the order of the libraries (in ‘scell_libs’ above). In earlier Python versions you would make consecutive calls of nd.replaceCells() with one library at a time to ensure the library order.
Ronald