Unable to insert DPolygon into layout

edited March 2015 in General
Hy all,

I just wanted to build a DPolygon out of several DPoints and insert it into my layout. The code looks something like this:

p1=RBA::DPoint.new(x1,y1)
p2=RBA::DPoint.new(x2,y2)
.
.
.
points=[p1,p2,...]
element=RBA::DPolygon::new(points)
cell.shape(layer).insert(element)

The error message says: "No overload with matching arguments in Shapes::insert"

With the non-double methods "Point" and "Polygon" everything works fine.
Has anyone an idea what I'm wrong?

Thanks for your help!

Comments

  • edited November -1

    Same problem and answer here: http://klayout.de/forum/comments.php?DiscussionID=584&page=1#Item_4

    Basically, there is no insert method that takes that argument. Use Point and Polygon, and divide all x and y coords by layout.dbu.

  • edited November -1
    Thank you, now it is working. I have achieved it with the "from_dpoly" function as suggested in the link you gave me.

    p1=RBA::DPoint.new(x1,y1)
    p2=RBA::DPoint.new(x2,y2)
    .
    .
    .
    points=[p1,p2,...]
    element=RBA::DPolygon::new(points)
    dbu=layout.dbu
    element=RBA::Polygon::from_dpoly(element*(1.0/dbu))

    cell.shape(layer).insert(element)
  • edited November -1

    A brief comment of mine: I'd like to discourage the use of the D-shape types because they inherit the numerical issues involved with floating-point values. Plus you should be aware of potential overflow issues when transforming the double types to integer types.

    If possible I'd use the integer types and work with dimensions expressed in terms if database units.

    Matthias

  • I again have the same issue with that script to copy a box from 1 layer to another layer :

      app = RBA::Application.instance
      mw = app.main_window
    
      lv = mw.current_view
      if lv == nil
      raise "No view selected"
      end
    
      cv = lv.active_cellview
      if !cv.is_valid?
      raise "No cell or no layout found"
      end
      cdbu = cv.layout.dbu
    
    
      sel_layers = lv.selected_layers
      if !sel_layers || sel_layers.size == 0
      raise "No layer(s) selected"
      end
    
      layer_info = LayerInfo.new(15,0)
      layer_index = lv.layer(layer_info)
    
      cv.layout.each_cell do |cell|
        sel_layers.each do |l|
          li = l.current.layer_index
          if cv.layout.is_valid_layer?(li)
               cell.shapes(li).each do |s|
                  if s.is_box?
                    p1 = s.box_p1
                    p2 = s.box_p2
    
                      box = RBA::Box.new(p1.x,p1.y,p2.x,p2.y)
              cell.shapes(layer_index).insert(box)
    
                  end
                end
            end
        end
      end
    

    I don't know where is my mistake ?

    Laurent

  • Hi Laurent,

    These lines

      layer_info = LayerInfo.new(15,0)
      layer_index = lv.layer(layer_info)
    

    need to be written as:

      layer_info = RBA::LayerInfo.new(15,0)
      layer_index = cv.layout.layer(layer_info)
    

    LayoutInfo needs to be qualified with the RBA namespace and "layer" is a method of the Layout object which you get from "cv.layout" as there can be multiple layouts in one view.

    BTW: the short version is simply:

      layer_index = cv.layout.layer(15, 0)
    

    Best regards,

    Matthias

Sign In or Register to comment.