Shortcuts for PCell creation.

Hi Matthias & all!
Can I somehow open the PCell instance creation pop-up from Python? And also tell it which library and cell to use?

I'm experimentally working on integrating the meep FDTD solver with KLayout. The idea is that additionally to the photonic layout also simulation specific shapes such as sources and monitors can be defined. I created some PCells for this purpose which works fine.
For usability I would now like to have a shortcut for creating those PCells.
I imagine adding 'Source' and 'Monitor' buttons next to Polyon/Box/Path buttons. They should be a shortcut for selecting the right library and the right cell.

Thanks in advance! :)

Comments

  • edited March 8

    Hi Thomas,

    this is basically possible:

    app = pya.Application.instance()
    
    mw = pya.MainWindow.instance()
    if mw.current_view():
      # Makes sure, the instance mode is triggered by resetting before:
      mw.cancel()
      # Configures some settings of the instance page:
      app.set_config("edit-inst-cell-name", "CIRCLE")
      app.set_config("edit-inst-lib-name", "Basic")
      # ... for more see "edit-inst-*" values in ~/.klayout/klayoutrc
      # Trigger instance mode
      mw.menu().action("edit_menu.mode_menu.instance").trigger()
    

    Every editing property can be configured - even PCell parameters which are encoded in "edit-inst-pcell-parameters" in a certain (hopefully self-explaining :) ) serialized way.

    Best regards,

    Matthias

  • Thanks Matthias!
    Setting the library did not work, so I did the following:

        #app.set_config("edit-inst-cell-lib-name", "MeepLib")
        app.set_config("edit-inst-lib-name", "MeepLib")
    

    This now works as intended but I don't know really what the difference should be between edit-inst-cell-lib-name and edit-inst-lib-name.

  • Hi Thomas,

    you're right - sorry, it's supposed to be "edit-inst-lib-name". I have edited to code above.

    Thanks for mentioning this.

    Best regards,

    Matthias

  • No problem! You're welcome :)

Sign In or Register to comment.