Best way to filter out non-mask data from shapes

edited December 2015 in Ruby Scripting

I wish to get a bounding box of the data in a cell and its
descendants. There's a catch, I want only mask layers to affect
this bounding box and I do not want text/labels to affect the
bounding box. I am given the list of mask layers.

What is the best way to do this?

Thanks
Dave

Comments

  • edited December 2015

    Hi Dave,

    you mean within a script?

    Here is one:

    ly = RBA::CellView::active.layout
    
    # layer/datatype of the mask layers
    mask_layers = [
      [ 1, 0 ],
      [ 2, 0 ]
    ]
    
    bbox = RBA::DBox::new
    
    mask_layers.each do |l,d|
      li = ly.find_layer(l, d)
      if li
        iter = ly.top_cell.begin_shapes_rec(li)
        iter.shape_flags = RBA::Shapes::SBoxes | RBA::Shapes::SPaths | RBA::Shapes::SPolygons
        while !iter.at_end?
          bbox += iter.shape.bbox.transformed(iter.trans) * ly.dbu
          iter.next
        end
      end
    end
    
    # prints the bounding box is micron units
    puts bbox.to_s
    

    It's not highly efficient since it will iterate over all flat shapes. A more elaborate solution is to cache the bounding boxes of the cells and take the instances' bounding boxes rather than iterating over their shapes.

    So it's not the "best way" but maybe a "reasonably simple way".

    Matthias

  • edited November -1

    Thank you. You actually helped with two questions. Firstly, I understand how to most efficiently get a bbox, and secondly, (this may come in handy for other forum readers) your code showed me how to make an undefined bbox suitable for starting to accumulate data extents. In other words, a box with left greater than right and bottom greater than top. I had no luck forcing a Box instance to do this with my own default values
    and should have guessed the DBox default would work.

    I really appreciate the help.
    Dave

Sign In or Register to comment.