Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Instance GUI invoked from a script

Hi Matthias,

Is it possible to invoke the Instance GUI (menu Edit | Mode | Instance) from a script? As an argument to the function call, I would like to 1) set the Cell and Library, 2) then query the list of PCell parameters, then 3) pass some PCell parameters to the GUI. Then via function, click "Apply" or "Ok", so that the GUI disappears, but the mouse is in the mode of showing the cell to be instantiated.

2 is above is already possible.

Thank you


  • Hi Lukas,

    sorry for the delayed response. The feature you ask for is not available out of the box, but it can be emulated (sorry, Ruby - but the Python transformation should be straightforward):

    app = RBA::Application::instance
    mw = app.main_window
    # if instance mode is one, make sure we leave it:
    # configure instance dialog:
    # cell placement
    app.set_config("edit-inst-angle", "0")
    app.set_config("edit-inst-mirror", "false")
    app.set_config("edit-inst-place-origin", "true")
    app.set_config("edit-inst-scale", "1")
    # cell origin
    app.set_config("edit-inst-cell-name", "CIRCLE")
    app.set_config("edit-inst-lib-name", "Basic")
    # PCell parameters: "coerced" form, notation is "name:value;...", value is:
    #   "#n" for integer
    #   "##d" for double
    #   "[layer:layer-spec]" for a layer
    #   "[dpoint:dpoint-spec]" for a double-typed point
    #   ...
    # peek into ~/.klayout/klayout under edit-inst-pcell-parameters for other
    # forms.
    app.set_config("edit-inst-pcell-parameters", "layer:[layer:1/0];radius:##10;handle:[dpoint:-10,0];npoints:#16;actual_radius:##10;")
    # array spec
    app.set_config("edit-inst-array", "false")
    # only if edit-inst-array is "true":
    app.set_config("edit-inst-column_x", "0")
    app.set_config("edit-inst-column_y", "1")
    app.set_config("edit-inst-row_x", "1")
    app.set_config("edit-inst-row_y", "0")
    app.set_config("edit-inst-columns", "10")
    app.set_config("edit-inst-rows", "10")
    # enter instance mode"edit_menu.mode_menu.instance").trigger
    # hide the dialog right after we opened it
    opt = RBA::QApplication::topLevelWidgets.find { |w| w.objectName == "EditorOptionsDialog" }
    opt && opt.accept

    The last statements are somewhat questionable as they rely on the widget hierarchy, but as long as there is no major UI update, this should work.

    Best regards,


Sign In or Register to comment.