Execute Ruby on Layout Load

Is it possible to auto-run a ruby code after a layout is loaded from a file (either through drag/drop or File=>Open) ? I would like to auto-select the technology and apply it so the correct layers show, based on either the file name or the encountered layers.


  • Hi!

    Looks like you could handle MainWindow.on_view_created event. Alternatively you could create macro that will ask user for file name with QFileDialog, call MainWindow.load_layout and perform other customizations.


  • Hi,

    I like the second proposal of Eugene.

    You can basically capture the events which indicated a new layout, but there is also the option to add a layout to a view which you also have to consider (with what consequences I don't know). If you want to go the way of the events, capture "on_view_created" to install a new event "on_file_open" for this view. This event will be triggered finally when a layout was loaded.


  • Hi,
    I am finally getting around to implementing this automatic tech switcher. I succeeded in the test case below: when the file is loaded, the technology switches and adjust the layers. However, the Technology Manager widget in the tool bar remains on the old, previous technology. Is there a way to programmatically switching that also ?



    module MyMacro
      include RBA
      # Enter your Ruby code here ..
         app = Application.instance
         mw = app.main_window
         mw.on_view_created do
             view = mw.current_view
             cell_view = view.active_cellview
             title =view.title
             tech_name = view.active_cellview.technology
             tech = RBA::Technology.technology_by_name(tech_name)
             $trt_root = File.dirname(File.dirname(__FILE__)) + "/macros"
             if title =~ /.*[sS][lL][sS].*/
                 mw.initial_technology= "SLS"
                 cell_view.technology = "SLS"
                 puts "NEW TECH = " + cell_view.technology
  • edited October 2020

    Oh yes, the tool bar thing ...

    Actually and unfortunately counter-intuitive, the tech button in the toolbar does not reflect the current layout's technology but rather the one you will apply if you push this button. It's the same logic that you have with the ruler: you select a ruler type and then push to activate it.

    This logic is shared by all elements of the toolbar, so I cannot simply change one.

    The technology your current layout carries is shown in the status bar next to the small "T" ("D25Test" in this case):

    Is this explanation helpful?


  • Hi Matthias,
    this confirms my fears. I take from your response that there is no good way of forcing the tech-button to show another item ? I understand that the technology has already switched, I just would like to also switch the tech-button from ruby to reflect that. However, it's also not a big deal :smiley:



Sign In or Register to comment.