Accessing all the Layers available in a Layout for PCell

edited July 2024 in Python scripting

Hi all,

I'm playing around with PCell and know that layers can be accessed using the param method. However, that limits to that single layer. Is there method to have access to all the layers that have been created for a particular layout?

I've tried using cell view but it will require re initializing library every time to get the latest layers and is very ghetto. The code below is the attempt I made for the issue.

`
def produce_impl(self):

layerDict = {}
activeLayout = pya.CellView.active().layout()
layers = activeLayout.layer_indexes()
for layer in layers:
  layerInfo = activeLayout.get_info(layer)
  if layerInfo.layer == -1 or layerInfo.datatype == -1:
    pass
  else:
    layerDict.update({layerInfo.layer:layerInfo.datatype})
    print(layerInfo.layer,layerInfo.datatype)
    self.layout.layer(layerInfo)

`

Comments

  • No, you can't.

    PCells are context agnostic. The client layout sees the PCell, but the PCell does not see the client. It runs in a sandbox environment without access to the client layout. The layout you see in the PCell is not the client one but the sandbox layout and it does not reflect the layers present.

    But it is unusual to have PCells that interact with the layout they are used in. PCells should be generic components you use to build your layout - for example devices or other PDK objects. PCells should not be objects that depend on the layout you are generating.

    Matthias

Sign In or Register to comment.