Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to draw labelled alignment marks?

Hi! I'm new to KLayout and I appreciate if someone can help me with my problem. I want to draw a 100x100 array of alignment marks, separated 150um in both X and Y directions, while each alignment mark is labelled by a polygon number including the row and column number separated by a point, similar to the attached image.

Would you please help me write a script for this purpose?
Thank you

Comments

  • Hi Hossein,

    The code below will generate the labels in a new cell called "ALL_LABELS". The size of the text is defined by the "magnification" variable.

    Cheers,

    Tomas

    module MyMacro
    
      include RBA
    
    # User input ---------------------------------------------------------------------
    
    layer = RBA::LayerInfo::new(1, 0)
    numberX = 100
    pitchX = 150.0
    numberY = 100
    pitchY = 150
    
    magnification = 10.0
    orientation = RBA::DTrans::R0
    
    #------------------------------------------------------------------------------------
    
    
    
    
    # select the layout of the current cellview
    main_window =  RBA::Application::instance.main_window
    layoutview = main_window.current_view
    layout = layoutview.active_cellview.layout
    
    # add a cell (in this case "ALL_LABELS")
    cell_index = layout.add_cell("ALL_LABELS")
    cell = layout.cell(cell_index)
    
    # find the lib
     lib = RBA::Library.library_by_name("Basic")
     lib || raise("Unknown lib 'Basic'")
    
    # find the pcell
     pcell_decl = lib.layout.pcell_declaration("TEXT")
     pcell_decl || raise("Unknown PCell 'TEXT'")
    
     #------------------------------------------------------------------------------------
    
    # create TEXT instances
    
    for i in 1..numberX do
    
      for j in 1..numberY do
    
          x = (i-1) * pitchX
    
          y = (j-1) * pitchY
    
          text = i.to_s.rjust(3, "0") + "." +  j.to_s.rjust(3, "0")
    
          # set the parameters
           param = { "text" => text, "layer" => layer, "mag" => magnification }
    
           # build a param array using the param hash as a source
           pv = pcell_decl.get_parameters.collect do |p|
           param[p.name] || p.default
           end
    
           # create a PCell variant cell
           pcell_var = layout.add_pcell_variant(lib, pcell_decl.id, pv)
    
           # instantiate that cell
           t = RBA::DTrans::new(orientation, x, y)
           cell.insert(RBA::DCellInstArray::new(pcell_var, t))
    
      end
    
    end
    
    #------------------------------------------------------------------------------------
    
    layoutview.add_missing_layers
    
    end
    
  • Hi Thomas,

    thanks for the code :-)

    It's still possible however, just to draw manually ... just place a "TEXT" PCell from the "Basic" library, go to the "PCell" tab in the instance properties and enter the layer and text you want to see.

    Matthias

  • Thank you so much Thomas and Matthias. This was exactly what I needed.
    Hossein

Sign In or Register to comment.