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()
a=pya.LayoutQuery.new("select cell.name, path_trans * cell.bbox, path_trans.disp.x, path_trans.disp.y from instances of ...*")
for q in a.each(layout):
print(q.data())

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

trying this gave attribute error

Thanks

Comments

  • 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?

    Matthias

  • hi @Matthias,
    I am using python for coding,
    I ran the following code -
    iter = layout.begin_shapes(C,c)
    while not iter.at_end():
    print(iter.shape().bbox())
    print(iter.shape().is_polygon(),iter.shape().polygon.transformed(iter.trans()).to_s())
    print(iter.cell().name)
    if iter.shape().is_polygon():
    polygon = iter.shape().polygon.transformed(iter.trans())
    print("In cell " + iter.cell().name + ": " + polygon.to_s())

    iter.next()
    
  • 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.