Application note: automatically load a companion .lyp file

edited February 2011 in General

I have received several requests with an intention like that:

"Is is possible to automatically load a layer properties file when a layout 
file is loaded where the layer properties file is located beside the layout 
file and named like the layout file?

For example: if a layout file xyz.gds is loaded and there is a layer 
properties file xyz.lyp in the same directory, it should be loaded 
automatically."

Although there is no explicit option to do so, KLayout can be configured to
achieve this behavior.

To do so, open the Setup dialog, go to "Application", "Layer List". Check the "Use default layer" checkbox and enter the following text into the text box below the checkbox:

$(combine(path(layoutfile),basename(layoutfile))+".lyp")

In that case, the $(..) expression is evaluated and replaced by a path consisting of the layoutfile's directory ("path(x)"), the filename without extension ("basename(x)") and the extension ".lyp". "combine(a,b)" combines the path components using the system specific separator character.

Hence, the layer properties file is derived from the layout file in the desired way. If there is no such file, no specific layer properties file is loaded.

Matthias

Comments

  • edited November -1
    Nice one!
  • edited November -1
    This is great. One of my wishlist items.
    Thanks!
  • Hi, just wondering if I could make a further feature request? Using the above script is really nice but we typically have a layer properties file, and a GDS that has the version tagged onto the end of the filename.

    I was wondering, if it's not already possible, to use the above dialogue to "run a script" that can be customised to do whatever you want it to? Sort of combining this thread with this one: https://www.klayout.de/forum/discussion/1998/layer-properties-lyp-file-name.

    Whilst it's convenient to have a script to run "on kLayout opening", it would be prefect to action a script to run "on GDS open".

    Thanks for your consideration!

Sign In or Register to comment.