Want to Open a Custom Extension File from Klayout

edited December 16 in General

I have a file with some custom extension e.g. sampleGds.aw which is kind of XML file so my usecase is if I double click this file and select Klayout to open it, the Klayout should receives the file path as an argument and then the Python macro (plugins) auto-runs to parse that file before the Layout view got created for it.

So wanted to ask is it supported?

If yes then how can i do that?

Comments

  • Hi @simransingh14,

    the option that comes to my mind is using a file type binding like

    klayout.exe -rm yourmacro.lym -rd input="%1"
    

    (I assume Windows style for file associations and %1 is replaced by the file name).

    In that case "yourmacro.lym" is a macro that reads the file using the "$input" (Ruby) or "input" variable defined by -rd, i.e.:

    ly = RBA::Layout::new
    ly.read($input)
    
    ... do other things
    

    Matthias

  • edited December 17

    Hi @Matthias

    Thank you for the reply.

    So I have one question I have created a macro file in my Klayout installation directory i.e. "C:\Users\abc\KLayout\pymacros\new_folder\TC_login.lym"
    can the above file be automatically executed when I open Klayout Application i.e. klayout_app.exe directly i don't want to execute it from the command prompt?

  • You can create a Application shortcut on Windows that includes the "-rm" option with the macro you are using.

    But I don't want to give Windows support here - there should be many resources which tell you how to create an application shortcut or bind some file extension to a specific handler.

    The key is the "-rm" option that KLayout offers to execute a custom macro when KLayout starts.

    Matthias

Sign In or Register to comment.