Selecting a cell instance only, not contents


When I instantiate a cell into another top cell and then select it in the top cell context, I now end up selecting the subcell contents.
Apparently, this is the default klayout behavior.
I NEVER want to do this, since there is a risk that I change the subcell by mistake.
When I double click on a cell instance, I only want to see the instatiation properties such as cell location and array params.
How can I change the klayout preferences to prevent access to the instantiated cell contents?



  • Menu Edit > Editor Options. Section Hierarchical Features: Shallow select: select "Select Top Level Objects Only" ?

  • It is worth asking, how someone could specifically
    change the default behavior. Like in a .klayoutrc
    entry of proper syntax? Or some other spot in the
    "init chain"?

    Is there a way to dump all settings that would lead
    to that syntax? Or maybe grab the options-change
    from a log file (this is how we used to get "stuff"
    for Cadence .cdsinit, .cdsenv customization, pick
    the SKILL barf from the CDS.log file and it was
    good to go).

  • edited February 2021

    Good question :)

    Basically KLayout keeps the settings persistent which makes you choice a kind of default.

    In klayoutrc the corresponding key is "edit-top-level-selection" and it's true to select top-level objects only.

    Inside some initialization script or in the macro IDE console you can modify this (and any other configuration property), by using

    # Ruby
    # shallow selection
    RBA::Application.instance.set_config("edit-top-level-selection", "true")
    # edit in place
    RBA::Application.instance.set_config("edit-top-level-selection", "false")
    # Python
    pya.Application.instance().set_config("edit-top-level-selection", "true")
    pya.Application.instance().set_config("edit-top-level-selection", "false")


    P.S. I'm going to get myself a T-shirt printed now. With big letters saying "Matthias. Not Cadence.". Or more big-headed: "Virtuos. Not Virtuoso.". I'm yet deciding :)

  • OK, so is there a way to dump to text file, or some
    documentation which lists all of the "keys", their
    purpose / functionality and their allowed values?
    I'm sure that there are many and that many may
    be obscure, but people might like to customize.

    Depending on persistence can get you in trouble,
    a good init file is key (heh) to environment

    You don't have to hate Cadence; there's plenty of
    people willing to do it for you. ;p

  • Hi Jim,

    you're right, persistence is for a single user only.

    Regarding the keys, the best list I can offer is the configuration file itself. Most values I think are self-explaining.

    You can actually dump the current configuration using small script:

    # some selection of keys not to dump (too user specific)
    drop_keys = [ 
      "current-ruler-template", "current-lib-view", "custom-macro-paths", 
      "macro-editor-active-macro", "macro-editor-console-mru", "macro-editor-open-macros", "macro-editor-current-macro",
      "macro-editor-window-state", "macro-editor-watch-expressions",
      "mru", "mru-bookmarks", "mru-layer-properties", "mru-sessions",
      "rdb-window-state-v2", "salt-manager-window-state",
      "window-geometry", "window-state",
      # This is the "default" technology:
    # Add the auto-execution preamble
    print("# $autorun")
    print("app = pya.Application.instance()")
    app = pya.Application.instance()
    for n in app.get_config_names():
      if not n in drop_keys:
        v = app.get_config(n)
        print("app.set_config(" + repr(n) + ", " + repr(v) + ")")

    This script will generate a script that you can install for other users to replicate your configuration.

    If you are in control of the KLayout installation this is how you roll out such a configuration:

    1. Save the output of the script to "" (example). Make sure the "# $autorun" line is the first line.
    2. In the KLayout installation - next to the KLayout binary - create a "pymacros" folder if it does not exist yet
    3. Copy "" to this folder.

    Now, every time a user runs KLayout, this script is executed (because of the "# $autorun" preamble) and your configuration is enforced on them.

    You can add more keys to the "dropped keys" list above to release more configuration settings from being controlled by your setup script. Or you could provide a configuration key whitelist instead. You're in control of what the user will be reset to.

    May be force be with you!


Sign In or Register to comment.