Layer properties (.lyp) file name

Hi Mattias,

Is there a way to define default layer properties file without specific file name?
I thinking about situation when we will have one .lyp file in the same directory as opening gds file and this .lyp file should be automatically loaded.
I was trying different combinations of special signs and .lyp extension (.lyp, "".lyp, "".lyp, .lyp etc.), but none of them work.
I don't want to have fixed name, as it can change in the different directories.
Do you think that it is possible?



  • If you have set up a "Technology" then the name /
    path for the .lyp is one of the entries in the forms.

    Technology choice is "sticky" so should autoload
    until you change technologies or somehow lose
    the remembered settings.

  • edited December 2021

    You could script such a feature in KLayout, but it's probably easier to create a shell wrapper like this simplified one:

    #!/bin/env bash
    klayout $file -l $(dirname $file)/*.lyp $*

    For a useful script you should at least add some error handling and sanity checks.


  • Thanks you both for response.
    I working on Windows, so this doesn't work for me.
    I was able to write basic Ruby script which adds lyp_import tab to the main window (in the Toolbar section).
    You need to click on it to load the lyp file (I also set this macro to run on start, so this tab is automatically added). Maybe it will be useful for someone else too (if there is more than one .lyp file the last one (sorted by name should be loaded).
    Here is the code:

    include RBA
    a =
    a.title = "lyp_import"
    file = Pathname("./").children(false)
    for x in file do
      if (x.to_s).end_with?(".lyp") then
        lyp_file = x.to_s
    a.on_triggered do
      ly = LayoutView::current
    menu =
    menu.insert_separator("@toolbar.end", "name")
    menu.insert_item("@toolbar.end", "my_action", a)


  • @Lidia Very good! Thanks a lot for sharing this code!

    Kind regards,


  • Hello,

    I like this concept and extended it a bit:

    1) when there is only 1 lyp file in the layout directory, it will be loaded.
    2) when there are multiple lyp files in the layout directory, and one has the same name as the layout file, it will be loaded.
    3) else, you will be asked to select the lyp file you want.

    The script will appear in the "File" menu before "Close".



    module MyMacro
        include RBA
        main_window = Application.instance.main_window
        layout_file = FileDialog.ask_open_file_name("Select Layout File", ".", "GDS files (*.gds *.GDS *.gds2 *.GDS2);;OAS files (*.oas *.OAS);;All files (*)")
        if !layout_file.empty?
            main_window.load_layout(layout_file, 1)
            layout_view = main_window.current_view
            layout_file_directory = layout_file.rpartition("/").first
            layout_file_name = layout_file.rpartition("/").last
            layout_lyp_file_with_same_name = layout_file_name.rpartition(".").first + ".lyp"
            lyp_files = Dir.glob("*.lyp")
            if lyp_files.size == 1
            elsif lyp_files.include? layout_lyp_file_with_same_name
                lyp_file = FileDialog.ask_open_file_name("Select lyp File", ".", "lyp files (*.lyp)")
                if !lyp_file.empty?
                end # if
            end # if
        end # if
    end # MyMacro
Sign In or Register to comment.