It looks like you're new here. If you want to get involved, click one of these buttons!
I was trying to add a basic text cell into a pcell. However the text is not rendered on the same layer.
def produce_impl(self):
lib = pya.Library.library_by_name("Basic")
pcell_decl = lib.layout().pcell_declaration("TEXT")
param = {"layer": self.layer, "text": "sample text"}
pv = []
for p in pcell_decl.get_parameters():
if p.name in param:
pv.append(param[p.name])
else:
pv.append(p.default)
t = pya.Trans(0, 0)
pcell_var = self.layout.add_pcell_variant(lib, pcell_decl.id(), pv)
self.cell.insert(pya.CellInstArray(pcell_var, pya.Trans.R0))
The layer is also not set in the pcell. What am I doing wrong?
I am using the following class: class pya.PCellDeclarationHelper:
Comments
Hi,
The code isn't complete so I can just guess. Basically it's correct - apart from a small enhancement: you don't need to translate the parameters to a list. You can directly pass the hash.
Here is some working example:
Here is the result:
BUT: you don't actually need to instantiate a PCell inside your code. You can generate text with the "TextGenerator" class. A PCell does the same but just in a very complicated way. To do so, replace "produce_impl" by this code:
It's not only shorter, it's also faster and does not generate internal-only subcells.
Matthias