-
Notifications
You must be signed in to change notification settings - Fork 264
Closed
Description
See https://www.klayout.de/forum/discussion/1152
The following code isn't working in the standalone module. In the application this will produce a layout with three circles.
Reason: gsi::Callback::can_issue (gsiCallback.h:76 and then pyaObject.cc:119) checks for pya::PythonInterpreter::instance() != 0 which is not the case for the standalone module.
import klayout.db as pya
# --------------------------------------------------------
# Library definition
class TestPCell(pya.PCellDeclarationHelper):
def __init__(self):
super(TestPCell, self).__init__()
self.param("l", self.TypeLayer, "Layer", default = pya.LayerInfo(1, 0))
self.param("r", self.TypeDouble, "Radius", default = 1000.0)
self.param("n", self.TypeInt, "Number of points", default = 64)
def display_text_impl(self):
return "Circle (l=%s,r=%.12g,n=%d)" % (str(self.l), self.r, self.n)
def produce_impl(self):
self.cell.shapes(self.l_layer).insert(pya.DPolygon.ellipse(pya.DBox(-self.r, -self.r, self.r, self.r), self.n))
class TestLib(pya.Library):
def __init__(self):
self.description = "Test library"
self.layout().register_pcell("Circle", TestPCell())
self.register("TestLib")
# create and register the library
lib = TestLib()
# --------------------------------------------------------
# Client code
lay = pya.Layout()
top = lay.create_cell("TOP")
output_file = "test.gds"
para = { "l": pya.LayerInfo(1, 0) }
pcell = lay.create_cell("Circle", "TestLib", para)
trans = pya.DCplxTrans.new(1, 0, False, 0, 0)
top.insert(pya.DCellInstArray(pcell.cell_index(), trans))
para = { "l": pya.LayerInfo(2, 0), "r": 750.0 }
pcell = lay.create_cell("Circle", "TestLib", para)
trans = pya.DCplxTrans.new(1, 0, False, 0, 2000.0)
top.insert(pya.DCellInstArray(pcell.cell_index(), trans))
para = { "l": pya.LayerInfo(2, 0), "r": 500.0, "n": 16 }
pcell = lay.create_cell("Circle", "TestLib", para)
trans = pya.DCplxTrans.new(1, 0, False, 0, 3000.0)
top.insert(pya.DCellInstArray(pcell.cell_index(), trans))
lay.write(output_file)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels