Make cell in Ruby

I want to make cell and all the shape within a area , that like this value...

x1=-9500.000001000
x2=7000.00000
1000
y1=-146000.000001000
y2=-144200.00000
1000

How can I do in Ruby code?
I have some idea as below...
But it is not workable....

main_window = RBA::Application::instance.main_window
layout = RBA::CellView::active.layout
layout_view = main_window.current_view
layoutView = RBA::Application::instance.main_window.current_view.active_cellview.cell
x1=-9500.00000*1000
x2=7000.00000*1000
y1=-146000.00000*1000
y2=-144200.00000*1000
iter = layoutView.begin_instances_rec_overlapping(RBA::Box::new(x1, y1, x2, y2)) 
while !iter.at_end
  ###get all the cell in the area.
  ####move these cell into a special cell.
  iter.next

iter = layoutView.each_shape
while !iter.at_end
  ###get all the shape in the area.
  ####move these cell into a special cell.
  iter.next

end ##while

Comments

  • I am sorry, I do not fully understand.

    So you want a clip of all shapes inside that area? There is a specific method for that: Layout#clip

    Matthias

  • Hi Matthias,
    checked with the notice of clip , look like it is what I need , but could you please pass me a sample?
    as below , I want to make all the pattern within the bbox area into a cell , and make it named "CELL_IO".
    in the document , I saw the description of clip , but I can't get the point for how to using that....

    Description: Clips the given cell by the given rectangle and produce a new cell with the clip
    cell:
    The cell index of the cell to clip
    box:
    The clip box in database units
    Returns:
    The index of the new cell

    main_window = RBA::Application::instance.main_window
    layout = RBA::CellView::active.layout
    layout_view = main_window.current_view
    layoutView = RBA::Application::instance.main_window.current_view.active_cellview.cell
    cells_to_delete = []
    x1=-9500.00000*1000  ##change dbu
    x2=7000.00000*1000  ##change dbu
    y1=-146000.00000*1000  ##change dbu
    y2=-144200.00000*1000  ##change dbu
    iter = layoutView.clip(layoutView,RBA::Box::new(x1, y1, x2, y2)) 
    
  • Here is some code I found in an older discussion. It produces a clip from the rectangle -1mm, -1mm to +1mm, +1mm (for database unit 0.001µm). Please note that the rectangle coordinates must be given in database units:

    layout = RBA::CellView::active.layout
    
    clip_rect = RBA::Box::new(-1000000, -1000000, 1000000, 1000000)
    clip_cell = layout.clip(layout.cell("TOP").cell_index, clip_rect)
    options = RBA::SaveLayoutOptions.new
    options.add_cell(clip_cell)
    layout.write("clip.gds", false, options)
    

    Matthias

  • Hi Matthias,
    Thanks a lot , I will try it.

  • Hi Matthas,
    After check , clip should not what the function I need , or maybe I have some miss for the script.
    As below , I using begin_shapes_rec_overlapping... to get what the pattern in special layer and where the place in the BBox.
    that is what the step1 ,
    in step 2 , I want to make these pattern and make it named "pattern".
    but....Look like I still need your help to learn how to process the pattern "pattern_item".

    layout = RBA::CellView::active.layout
    ly = RBA::Application::instance.main_window.current_view.active_cellview.layout
    layoutView = RBA::Application::instance.main_window.current_view.active_cellview.cell
    x1=-12596.05000*1000
    x2=12596.05000*1000
    y1=-14673.14500*1000
    y2=14673.14500*1000
    l1 = layout.layer(75,0)
    pattern_item = layoutView.begin_shapes_rec_overlapping(l1,RBA::Box::new(x1, y1, x2, y2)) 
    
    while !pattern_item.at_end?
      if pattern_item.shape.renders_polygon?
        polygon =pattern_item.shape.polygon.transformed(pattern_item.itrans)
        puts "In cell #{pattern_item.cell.name}: " + polygon.to_s
      end
      iter.next
    end
    
    #

    in this code , the function is what I want to do....
    I can copy all the shape (in layer 154,1) , change layer and copy pattern int cell.
    but I can't choose the pattern by BBox area...

    layout = RBA::CellView::active.layout
    ####create shape into cell and 
    
    bumplayer=input(154,1)
    bumppadlayer=94
    bumppadpur=0
    workcell="pattern"
    if  !layout.has_cell?(workcell) then
    layout.create_cell(workcell)
    end
    
    l1 = layout.layer(bumppadlayer,bumppadpur)
    top = layout.cell(workcell)
    bumplayer.data.each do |poly|
    top.shapes(l1).insert(RBA::Polygon::new(poly))
    end
    
    placeme = source.layout.cell(workcell) 
    source.cell_obj.insert(RBA::CellInstArray::new(placeme.cell_index, RBA::Trans::new(0,0)))
    
  • edited May 2022

    This is a DRC script, isn't it? This is a DRC statement:

    bumplayer=input(154,1)
    

    If you're in DRC, why not just doing:

    x1=-12596.05000
    x2=12596.05000
    y1=-14673.14500
    y2=14673.14500
    
    clip(x1, y1, x2, y2)
    
    input(154, 1).output(94, 0)
    

    ?

Sign In or Register to comment.