preserve user property with layer sizing

jpujpu
edited October 2015 in KLayout Support
Hello,
I would like to enlarge all shapes on a layer e.g. by the command "Edit -> Layer -> Size".
The Problem is, that the enlarged shapes loose the user properties.
Is there a workaround for this behavior?

The background is, that I need to Export a list of all structures biased by a certain amount, but with a tag to identify different structures.

Regards
JP

Comments

  • edited November -1

    Hi JP,

    the layerwise geometrical functions under "Edit/Layer/.." don't preserve properties in general since they act on polygons and will not preserve the polygons in the general case. They also won't preserve the hierarchy if there is one. They are pure flat polygon operations.

    The size function is basically capable of preserving polygons as such, but it's quite easy to create cases where polygons join (positive sizing), split (negative sizing) or even vanish. Preserving properties in these cases is heavily depending on the interpretation of the properties and not supported therefore.

    I think it's possible to preserve them on "Edit/Selection/Size shapes", but right now that also doesn't happen.

    Here is a script which will size the selected shapes while preserving the properties:

    bias = 0.1  # CHANGE VALUE
    
    mw = RBA::Application::instance::main_window
    view = mw.current_view
    
    begin
    
      view.transaction("size selected shapes (with preservation of properties)")
    
      sel = view.object_selection
    
      sel.each do |s|
    
        if !s.is_cell_inst? && !s.shape.is_text?
    
          ly = view.cellview(s.cv_index).layout
    
          # convert to polygon and size
          # use a RBA::Region object for that purpose 
          region = RBA::Region::new(s.shape.polygon)
          region.size(bias / ly.dbu)
          polygons = []
          region.each { |p| polygons << p }
    
          # only replace the polygon if the sizing operation rendered
          # exactly one polygon
          if polygons.size == 1
            s.shape.polygon = polygons[0]
          end
    
        end
    
      end
    
      view.object_selection = sel
    
    ensure
      view.commit
    end
    

    If the sizing renders zero or more and than polygon, this function does nothing. Plus: if a shape is selected multiple times through the hierarchy it may receive the sizing multiple times as well.

    Matthias

  • jpujpu
    edited November -1
    Hallo Matthias,
    nett mal wieder in Kontakt zu kommen!
    Thanks for the code and the explanations.
    It solved my Problem, i.e.

    JP
  • edited November -1

    JPU ... klar! Jetzt klingelt's :-)

    Melde Dich doch mal auf dem nichtoeffentlichen Kanal!

    Matthias

Sign In or Register to comment.