difference between -z and -zz command line options

edited January 2016 in General

Hello,

Im wondering what the difference beteen -z and -zz because i was originally using -b option from command line to hide the GUI. I ran into a problem where I wasn't able to flatten a cell because i was using -zz/-b.

I read that -b is same thing as -zz option but -b is not on the listed command_args. http://www.klayout.de/command_args.html

The code below works when using -z but not when using -zz command line argument.

module MyMacro
  include RBA
  RBA::Application.instance.exec
  layout = RBA::Layout::new
  layout.read("C:\\TEMP\\test.gds")
  cell = layout.cell(layout.top_cell.cell_index)

  layout.flatten(layout.top_cell.cell_index,-1,true)
  layout.write("C:\\TEMP\\test_flat.gds")
end

Thanks,
Keil

Comments

  • edited November -1

    Hi Keil,

    Oh yes, the documentation was a bit outdated. It's been fixed.

    First of all in your code "RBA::Application.instance.exec" is not required - it is only required to show the application's main window. It's a somewhat outdated feature. Originally, there was no "-rm" option and no "autorun" feature for scripts. So the only way to perform actions before the application started (for example installing special menus) was to write code code with "RBA::Application.instance.exec" at the end. This would execute your code and finally fire up the user interface. So today better forget about this statement.

    If you omit that line your scripts should execute perfectly. In "-z" mode this line simply does nothing. If "-zz" mode, the Application object is not there and you will get an error. And with this I come to the main point: the difference between both modes is the absence of everthing user-interface related in "-zz" mode. In "-z" mode you can still open some user interface if you need one (a message box, an input dialog, a custom dialog using the Qt elements or even the application itself). In "-zz" you can't. On Linux this implies you don't need a $DISPLAY in "-zz" mode and "-zz" (specifically "-b") is starting faster and requires less memory. Your script is a perfect example for this use case: you just want to perform some action on a layout and hence you can drop the user interface overhead entirely.

    Regards,

    Matthias

  • edited February 2016

    Thanks for the explanation Matthias.

    I commented out the "RBA::Application.instance.exec" and it works for -z but still does not work when using -zz or -b.

    module MyMacro
      include RBA
      #RBA::Application.instance.exec
      layout = RBA::Layout::new
      layout.read("C:\\TEMP\\test.gds")
      cell = layout.cell(layout.top_cell.cell_index)
    
      layout.flatten(layout.top_cell.cell_index,-1,true)
      layout.write("C:\\TEMP\\test_flat.gds")
    end 
    

    So I then commented out "layout.flatten(layout.top_cell.cell_index,-1,true)" and tested it again. This time "-z" and "-b" worked but "-zz" did not.

    module MyMacro
      include RBA
      #RBA::Application.instance.exec
      layout = RBA::Layout::new
      layout.read("C:\\TEMP\\test.gds")
      cell = layout.cell(layout.top_cell.cell_index)
    
      #layout.flatten(layout.top_cell.cell_index,-1,true)
      layout.write("C:\\TEMP\\test_flat.gds")
    end 
    

    So it seems like "-b" doesnt work if flatten is in program. "-zz" dosnt work either time.

    I am using Klayout 0.24.2 64 bit on windows. I dont mind using -z just wanted you to know.

    Thanks,
    Keil

  • edited November -1

    So I swore the code above worked last week. Now i get an error when I try calling the code above with '-r' or '-z -r'.

    The error I get is 'Internal error: c:\klayout\0.24\src\dbInstances.h:1761 is_editable () was not true in Layout::flatten'.

    Why does this error come up? I dont have a folder on my PC called 'C:\klayout'. Is this folder suppose to be created when program installs. I reinstalled klayout and still get same error and no folder 'c:klayout'

    Thanks,
    Keil

  • edited November -1

    Hi Keil,

    the explanation is that "flatten" is a function that requires an "editable" layout. "editable" layouts have some capabilities that flatten requires. On the other hand, editable mode comes with some overhead that other applications do not require.

    You can force a layout into editable mode using this constructor:

    layout = RBA::Layout::new(true)
    ...
    

    With this change, your script works in any case.

    In KLayout up to 0.24, the layout object was by default created with the application's mode. So if you start in edit mode with "klayout -e ...", the script works. In viewer mode "klayout -ne ..." the script does not work. In default mode, the application will use the mode you configured in the setup dialog as "default mode". I assume you have configured viewer mode now.

    Anyway .. with the above constructor, you don't need to worry about the application mode and it works with -z, -zz, b and probably most other options. In version 0.25 I will change the default constructor of RBA::Layout to always create an editable layout to avoid this confusion.

    Regards,

    Matthias

Sign In or Register to comment.