scripting import LEF/DEF

edited January 2018 in General
I would like to create a menu that loads a lef+def file on an existing opened design. Exactlty what I would do by File->import->LEF/DEF and selecting "Import as new layout is the same panel"

The command I use for launching klayout is :
klayout -e -u KLAYOUT/results/gds.lyp -rm ./fastkit_macro.lym

where gds.lyp gives the gds and associated layerProps

the macro I defined for loading the def is as follows but is does not work at all
(stream format is not correct)

module FastkitMacro2
include RBA
$fastkit_action =
$fastkit_action.title = "load_DIAG"
$fastkit_action.on_triggered {
app = RBA::Application.instance
mw = app.main_window
menu =
menu.insert_item("end", "fastkit", $fastkit_action)

Is there a method that can load this format ?


  • edited November -1

    Hi Paul,

    did you try with the latest version (0.25)? For this version, it should be possible to load DEF like any other format.

    DEF is richer, so if you want to provide particular configuration options, you'll need a separate configuration object:

    options = RBA::LoadLayoutOptions::new
    lefdef_options = RBA::LEFDEFReaderConfiguration::new
    # configure lefdef_options, i.e.
    # lefdef_options.dbu = 0.00025
    options.lefdef_config = lefdef_options
    view.load_layout(filename, options, true)

    For LEF/DEF reader options see


    • You don't need to create RBA::Action in your code above - just configure the macro to show up in the menu. The macro essentially will become a two-liner.
    • The last parameter of view:load_layout is a bool (2 will be taken as 'true')



Sign In or Register to comment.