It looks like you're new here. If you want to get involved, click one of these buttons!
I'm reading a pre-defined layer .lyp file into Klayout and run readLayer() to fill a WidgetTable form.
Issues I would like to solve is that if a layer index doesn't exist I can't set the layer properties.
Only if I create a new layer or a layer is used already to draw a shape the layer is recognized.
Is there a method to build a layer index with an empty layout and an imported .lyp?
Thanks in advance for your valued feedback.
Andy
def readLayer():
config()
lv.add_missing_layers()
lv.update_content
Liter = lv.begin_layers()
while not Liter.at_end():
lp = Liter.current()
if(lp.layer_index()>= 0 ): # required because otherwise the procedure will crash if no valid layer index exist
info = layout.get_info(lp.layer_index())
#print('Selected Layer:', info.name, info.layer, info.datatype)
numRows = dialog.tW.rowCount
dialog.tW.insertRow(numRows)
dialog.tW.setItem(numRows,0,QTableWidgetItem(str(info.name)))
dialog.tW.setItem(numRows,1,QTableWidgetItem(str(info.layer)))
dialog.tW.setItem(numRows,2,QTableWidgetItem(str(info.datatype)))
Liter.next()
Comments
Hi Any,
there is one issue here: the .lyp file specifies a "source" which may be only partially specified. If for example, the source gives the layer and datatype, the name can only be obtained after the layout way read and this name can be taken from the database. If no such layer is there, you can use the intended layer:
If you're just interested in what the .lyp file will tell you, just use "lp.source_..." instead of asking the layout object.
Regards,
Matthias
Thanks a lot Matthias,
works perfect ...
Reason for this implemetation is that the klayout user would like have a quick way to add a layer name and changing the datatype. You could do this with KL functionalty but only layer per layer. The following script uses a tableWidget to run it in one step.
Nice idea :-)
Actually layer sources and the layer views are much more powerful, so I don't think you can capture the full beauty in a single table (i.e. hierarchies, transformations, property selectors, tabs etc.). But for certain applications that's surely sufficient.
The applications I know usually produce .lyp files from some tech database or technology description files for the original source. That can also be scripted.
Regards,
Matthias