Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymod branch: reimplemented methods are not getting called #197

Closed
klayoutmatthias opened this issue Nov 18, 2018 · 1 comment

Comments

@klayoutmatthias
Copy link
Collaborator

commented Nov 18, 2018

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)
@klayoutmatthias

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 19, 2018

Was fixed with 934bed7 in pymod branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.