How to extract the coordinates of an object or specific shape or cell from the layout in python

hi, I am new to Klayout appreciate it if i can get any help.
I need to get the coordinates of the objects (lower left and upper right) in diffrent layouts. I tried the following code

layout=pya.Layout()"select, path_trans * cell.bbox, path_trans.disp.x, path_trans.disp.y from instances of ...*")
for q in a.each(layout):

error - 'module' object has no attribute 'LayoutQuery' (Class exceptions.AttributeError)

trying this gave attribute error



  • Hi, Bharat!

    See this discussion as example.

  • thanks @EugeneZelenko it helped a lot.

  • I see the code is some mix of languages. What are you using? Python or Ruby?


  • hi @Matthias,
    I am using python for coding,
    I ran the following code -
    iter = layout.begin_shapes(C,c)
    while not iter.at_end():
    if iter.shape().is_polygon():
    polygon = iter.shape().polygon.transformed(iter.trans())
    print("In cell " + iter.cell().name + ": " + polygon.to_s())
  • Would you mind formatting the code properly? There is a "code" paragraph style in the editor for the comment. This is not readable, in particular not for Python.

    And what's the message? Do you see an error? Unexpected results?

Sign In or Register to comment.