How to retrieve xy information from polygon edge in absolute transformations format

edited July 2015 in Ruby Scripting
When I am using KLayout in interactive mode, if i double click on any selected polygon, then I can choose coordinate display format with checking on "Absolute (accumulated) transformations" check box. But when I try to use Ruby script in order to retrieve xy on edges of polygons, it will only return coordinate without absolute transformation.

app = Application.instance
mw = app.main_window
lv = mw.current_view
lv.each_object_selected do |sel|
shape = sel.shape
if shape.is_polygon?
ply = shape.polygon
ply.each_edge {
|ed|
p1_s = ed.p1
x1 = p1_s.x --------->
y1 = p1_s.y ----------> Not in absolute transformation format.
}

end

Comments

  • edited November -1

    Hi,

    "sel.trans" will give you the transformation of the polygon into the current cell. "sel.trans.trans(p)" will transform a point into the current sel. Hence:

    ply.each_edge do |ed|
      p1_s = sel.trans.trans(ed.p1)
      # -> will give you p1_s in absolute coordinates
    end
    

    Matthias

  • edited November -1
    Thanks, Matthias.
Sign In or Register to comment.