How to get all the cell / polygon object in special area.

Hi Sir ,
in Ruby , how to get cell / polygon pattern / object in a special area?
such as ...
cell : DIE
BBox (500,500) , (-500,-500)
that means I want to get the sub cells in the top cell "DIE" , and get cell within BBox area only.
in Ruby / Python , how to do that?

Comments

  • edited June 2021

    @jiunnweiyeh You can use the RecursiveShapeIterator for this purpose.

    ly = ... your layout ..
    top = ly.top_cell
    layer = ly.layer(1, 0)   # TODO: takes layer 1/0
    iter = top.begin_shapes_rec_touching(layer, RBA::Box::new(-500, -500, 500, 500))  # TODO: adjust box
    while !iter.at_end
      if iter.shape.is_polygon?
        poly = iter.shape.polygon.transformed(iter.trans)
        # TODO: do something with poly ...
      else
        # TODO: other shape types
      end
      iter.next
    end
    

    Matthias

  • Hi Matthias,
    for the code ly=.......your layout ,
    Is it means that like this code?

    LayoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout

    Another new question is ... how to draw a box in current cell?
    It may like this one....
    layer = ly.layer(1, 0)
    iter = top.create_shapes_rec(layer, RBA::Box::new(-500, -500, 500, 500))

  • @jiunnweiyeh Yes, you somehow need to address the layout you're taking the shapes from. To get the current layout, use "RBA::CellView.active.layout".

    I can't say how you want your box to be defined. I just used the coordinates you have given.

    Matthias

  • @Matthias
    Could you please help to check that how to remove a cell if get it from begin_instances_rec_overlapping ?
    as below code , I can get cell (include cell name / location...) after that command.
    then I want to remove (delete) that cell.
    But that is not workable....

    viewed_cell = layout_view.active_cellview.cell
    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
    iter = layoutView.begin_instances_rec_overlapping(RBA::Box::new(x1, y1, x2, y2)) 
    while !iter.at_end
        if iter.inst_cell.name.match(bumpcell) then
        iter.delete ####remove cell
        end ## if instance cel name match
      iter.next
    end ##while
    
  • Don't delete during iteration - this will crash the application.

    Instead collect the cells to delete and delete later, e.g (untested):

    cells_to_delete = []
    iter = layoutView.begin_instances_rec_overlapping(RBA::Box::new(x1, y1, x2, y2)) 
    while !iter.at_end
        if iter.inst_cell.name.match(bumpcell) then
            cells_to_delete << iter.inst_cell.cell_index
        end ## if instance cel name match
      iter.next
    end ##while
    
    ly.delete_cells(cells_to_delete)
    

    Matthias

  • @Matthias
    Thanks , it is work.

Sign In or Register to comment.