We use instance properties to keep track of some metadata in the cell hierarchy. In KLayout 0.30.8, instance properties of child instances inside PCells are not preserved once the PCell is done generating.
Consider the following script, either as python macro in KLayout or as a standalone python script:
import klayout.db as pya
class DummyPCell(pya.PCellDeclarationHelper):
def __init__(self):
super(DummyPCell, self).__init__()
def produce_impl(self):
child_cell = self.layout.create_cell("CHILD")
inst = self.cell.insert(pya.DCellInstArray(child_cell.cell_index(), pya.DTrans()))
inst.set_property("id", "my_id")
print("Inside PCell:", [inst.properties() for inst in self.cell.each_inst()])
class MyLib(pya.Library):
def __init__(self):
self.description = "Dummy Library"
self.layout().register_pcell("DummyPCell", DummyPCell())
self.register("MyLib")
MyLib()
layout = pya.Layout()
top_cell = layout.create_cell("TOP")
# Insert a dummy pcell
dummy_cell = layout.create_cell("DummyPCell", "MyLib", {})
dummy_cell_inst = top_cell.insert(pya.DCellInstArray(dummy_cell.cell_index(), pya.DTrans()))
# Query properties
print("After inserting PCell:", [inst.properties() for inst in dummy_cell.each_inst()])
In 0.30.8, the output is:
Inside PCell: [{'id': 'my_id'}]
After inserting PCell: [{}]
In 0.30.7 and before the properties are still attached to the instance:
Inside PCell: [{'id': 'my_id'}]
After inserting PCell: [{'id': 'my_id'}]
We use instance properties to keep track of some metadata in the cell hierarchy. In KLayout 0.30.8, instance properties of child instances inside PCells are not preserved once the PCell is done generating.
Consider the following script, either as python macro in KLayout or as a standalone python script:
In 0.30.8, the output is:
In 0.30.7 and before the properties are still attached to the instance: