Using Search and replace tool to convert paths into polygons

Hi,

I have a layout that has a lot of paths. I want to turn them all into polygons. I tried using the custom query option in the "Search and Replace" tool using the query:

with paths on layer 1/0 from cells * do shape.path.polygon()

It doesn't throw an error at me however it also doesn't convert any of the paths. Does anyone know if this is possible to do, and if not any ideas on how I can convert all my paths into polygons?

Thank you!

Comments

  • If you put a minuscule "box" object on the same layer and
    inside the path's edge-edge extents, and select them both,
    the Merge function will combine them into a polygon.

  • Hi,

    Thanks for the help! Since I have numerous path objects in a complex cell hierarchy, I didnt want to change all of them by hand, which is what merge shape would make me do( I think). I was hoping for a scripted approach.

    I also wrote this little script however it doesn't appear to work too well:

    for inst in cell.each_shape(layer):   
        if inst.is_path():  
            inst.path.polygon();    
    
  • I found a way :) If anyone is looking for the same thing

    from SiEPIC.utils import get_layout_variables
    
    TECHNOLOGY, lv, ly, cell = get_layout_variables();
    
    for inst in cell.each_shape(layer):   
      if inst.is_path():
        a=inst.polygon;
        inst.polygon=a #polygon= is another method 
    
    
  • Yes, that's it :)

    You could even write "inst.polygon = inst.polygon" :)

    Matthias

  • Hello,

    I have a similar problem: convert boxes to polygons.
    I used this code in version 0.24.8 and it worked fine.
    Now I'm using 0.26.11 and I get an error ( ReuseVector.h:277 mp-v->is_used(m_n) was not true in Shape::polygon ). After you clear the messagebox popup, you see that the box was actually converted.

    mw = RBA::Application::instance::main_window
    view = mw.current_view
    sel = view.object_selection
    sel.each do |s|
    if s.shape.is_box?
    s.shape.polygon = s.shape.polygon
    end
    end

    The class help says not to set the polygon this way when iterating over a list.
    What is the right way?

    Thanks,

    Dave

  • edited April 14

    @djdougherty Hi Dave

    I can't confirm your observation but I have an explanation.

    With a simple, flat test case, your example works without errors for me.

    However, it's possible to screw up things: if I select shapes from subcells and select the same shape twice, but in different instances of the same cell, I can reproduce the error.

    The reason is that the second time you visit the same shape again, it has already been converted, so the original reference got lost. This is what the error is basically saying.

    You can work around this duplicate visit problem by adding

    if s.shape.is_valid? && s.shape.is_box? 
     ...
    

    Please note that "is_valid" isn't entirely foolproof. It says the shape is gone, but if in your loop you add boxes, the shape may become valid again as the slot gets filled with a new box and "is_valid" isn't an indication that the shape had been converted.

    Matthias

Sign In or Register to comment.