How can I record a macro

edited August 2019 in Ruby Scripting

If I want to select a shape (say Metal1), copy it to a different layer (say Via1), and go edit->selection->size shapes, to size it down by 1um, is there a way to show the command lines somewhere so that I can record this series of operations and put the codes into a Ruby macro?

Sorry I am fairly new to scripting. So instead of going through the lengthy API document, I am hoping to find an easier way to learn the command line scripts.

Thanks

Comments

  • Here is what I have so far, with questions embedded

    app = RBA::Application::instance
    mw = app.main_window
    view = mw.current_view
    mw.cancel

    sel = view.object_selection

    How do I apply the menu command to the slected object?

    mw.menu.action("edit_menu.copy").trigger
    mw.menu.action("edit_menu.paste").trigger
    mw.menu.action("edit_menu.selection_menu.size").trigger

    How do I pre-enter the size parameter?

    mw.menu.action("edit_menu.selection_menu.change_layer").trigger

    How do I specify the layer?

  • edited August 2019

    Hi,

    the menu functions route to the internal implementation. There is no way to access the details by script, because scripts provide only some kind of "side entrance" rather than mapping the basic API. Hence, there is no recording. On the other hand, the API offers access to functionality for which there isn't a UI.

    Scripting works on a different level: for example, you would not copy/paste, but rather work with the data objects (in your case: collect the polygonized shapes in a RBA::Region object). There is a lot to say about this, but that requires a deeper understanding of the API. I'm sorry, but the deal with open source is that you either accept it the way it is or contribute (or sponsor) an enhanced implementation.

    Here is the "API style" solution I think you are looking for. It lacks handling of some errors (e.g. no layout loaded etc.), but basically it should work:

    cv = RBA::CellView.active
    ly = cv.layout
    
    # TODO: replace target layer (here: GDS layer 8, datatype 0)
    target_layer = ly.layer(8, 0)
    
    res = RBA::Region::new
    
    lv = RBA::LayoutView.current
    lv.each_object_selected do |sel|
      if !sel.is_cell_inst?
        res.insert(sel.shape.polygon.transformed(sel.trans))
      end
    end
    
    # TODO: insert size value in DBU units
    size_value = -10 
    
    res.size(size_value)
    
    lv.transaction("Size and copy selected objects")
    begin
      cv.cell.shapes(target_layer).insert(res)
    ensure
      lv.commit
    end
    

    Matthias

  • This works. And it's so concise. I love it. Thank you Matthias!

Sign In or Register to comment.