Flatten
When a cell is “flattened”, all child cells are resolved and the shapes
are propagated into the parent cell.
See flatten
documentation for details
about this feature.
Note: this operation is potentially expensive. Depending on the hierarchical organization, this may create a large number of shapes even from few cells.
Code:
import klayout.db as db
import math
ly = db.Layout()
ly.read("nuts_and_bolts.gds")
# arguments are: levels (-1: all), remove orphan cells
ly.top_cell().flatten(-1, True)
ly.write("flatten.gds")
Input nuts_and_bolts.gds
:
Result (looks the same, but actually is flat):