It looks like you're new here. If you want to get involved, click one of these buttons!
Sounds simple but I'm struggling with the following issue:
Running klayout in batch mode:
1) I create a new cell - layout.create_cell('abc')
2) switch into this cell - similar show as new top in the GUI mode
3) add some shapes right into the cell
4) switch back to the top level
My question is how to model the show as new top command in python?
def createLayout(topCellName):
layout.create_cell(topCellName)
topcell = layout.top_cell()
print('Layout created: '+topcell.name)
def switchTop(top):
cell = pya.CellView.active()
cv.cell_name = top
print('Change to cell: '+top)
def newCell(top,cellName,x,y):
dummy = layout.create_cell(cellName)
for cell in layout.each_cell():
if (cell.name == top):
cell.insert(pya.CellInstArray(dummy.cell_index(),pya.Trans(pya.Point(x*dbu,y*dbu))))
print('new cell generated: '+cellName+' in Hierarchy '+top)
####
createLayout('myTop')
newCell('myTop','abc',0,0)
newCell('abc','dfe',0,0)
switchTop('abc')
### Insert shapes into hierarchy cell
#TOP=layout.top_cell() # insert shapoes in top cell
#TOP.shapes(myLayer).insert(pya.Box(x1*dbu, y1*dbu, x2*dbu, y2*dbu))
# work but need to provide cell name
cell=layout.cell('abc')
cell.shapes(myLayer).insert(pya.Box(x1*dbu, y1*dbu, x2*dbu, y2*dbu))
Best Regards,
Andy
Comments
Hi Andy,
some things are really easy:
:-)
Matthias
Hello Matthias,
sometimes it's the obvious we don't see ... Thanks a lot.
My main target is to create a bunch of 'super' commands to ease the shape generation.
Those macro language is stored in the python directory and imported as a module into python. I finally run klayout -b- r test.py to generate the shapes.
Up to now I defined:
Example test.py:
In future I want to use your new development in PyPi to import the Klayout module into python. This way I could more easy access other python modules. Looking forward to the first trials.
Best Regards,
Andy
Hi Andy,
that the beauty of a dynamic language - everyone can tailor it to his or her needs :-)
I personally like Ruby better for this kind of thing. You can essentially turn it into something entirely different (look at Rails or KLayout's DRC or XS script). But that's of course a matter of taste.
Regards,
Matthias