Accumulated postion of an instance

edited November 2017 in General
Hi ,
Can someone please help me how to write the script for getting the accumulated position of an Instance?I tried so many different ways but without success.

Thanks.

Comments

  • edited November 2017

    Hi,

    please give some more details. Do you get the instance from an selection? Which cell do you want to sum up the transformations to? Could you please paste some code that illustrates your problem?

    Matthias

  • edited March 2019

    Hello,
    This question is also of interest to me.
    If I have selected a shape, how can I get the absolute transformation in a Python script? In other words, inside a script, how can I get the value that is displayed in the user interface window "Object properties" when the box "Absolute (accumulated) transformation" is selected?
    Olivier

  • Any hint or pointer?

  • Hi ocasta,

    if you retrieve the selection with "each_object_selected", you will get "ObjectInstPath" objects. Their "trans" property tells you the accumulated transformation.

    Matthias

  • Thank you very much. I start to understand better. Let me ask something more...
    How can I know the accumulated positions of all the instances of a given Cell in the full layout?

    • is it possible to populate the selection programmatically? How?
    • or shall I do a recursive parent search myself?

    Olivier

  • Hi Olivier,

    there is a related post here: https://www.klayout.de/forum/discussion/1175/extract-information-from-oasis-file#latest

    It's basically the same question.

    Regards,

    Matthias

  • Hello,
    The link that you provided advises to use a LayoutQuery. This is a good solution in some cases, but it often happens that this type of search is inefficient, in the sense that it takes ages and full cpu power to obtain a result. In order to have an immediate result, I wrote a recursive parent search (upward search). See the attached file (remove the .txt extension).
    Comments, questions, and improvements are welcome.
    Olivier

  • Hi Olivier,

    The LayoutQuery was just an suggestion. It's not good for finding the instances of a single cell. The question in the mentioned post was generic and so was my answer.

    If you look for a specific cell (e.g. "THE_CELL"), a query like "select path_trans from instances of ...THE_CELL" should not be much slower than the Python script. Do have evidence for a much slower case?

    But anyway thanks for sharing this code.

    I understand it's eventually a wrapper around the graph to provide instantiation paths across multiple levels of hierarchy. Such instantiation paths are a core feature of the C++ API, but not all the concepts are exposed to Python or Ruby.

    Kind regards,

    Matthias

  • If I understand your message correctly, you advise to use the query "instances of ...THE_CELL".
    This is already what you advised in the link that you mentioned above, isn't it?

    Do have evidence for a much slower case?

    Yes I do have evidences. I extracted a part of a design that shows the problem and I can send it to you (maybe we can arrange that in a private message). The size of that OAS file is 1 Mb. The two methods perform very differently:

    • The Search/Replace query "instances of ...THE_CELL" takes 5 min at 100% cpu before giving the result (on my laptop).
    • On the contrary, my script returns the result instantaneously.

    I wouldn't call this a wrapper, because in my definition, a wrapper only acts as glue code, it does not perform any other action. Here, I construct the "instance graph" upward, based on the "cell graph" that is accessible through the API.

  • Hi ocasta,

    "instances of ...THE_CELL" is a modification of the original query: while the original suggestion was looking for all cells (that's how I understood the question), the modified query looks for one specific cell. That should definitely make a difference.

    So for example, when you look for all instances of a cell called "VIA", you can use (note the VIA after "..."):

    select path_trans * cell.bbox, path_trans.disp.x, path_trans.disp.y from instances of ...VIA
    

    rather than the original approach which was using

    select cell.name, path_trans * cell.bbox, path_trans.disp.x, path_trans.disp.y from instances of ...*
    

    and selecting the given cell from the result.

    The specific approach should definitely be faster. If it isn't I shall investigate that issue.

    I'm kind of interested in the query solution because I think it's a very flexible approach to answer a lot of questions of the kind you had. So I'd like to make it usable as far as possible.

    Regards,

    Matthias

  • Hello Mathias,

    • I was already using the solution that you advise. Indeed, as mentioned in my last post, I use "instances of ...THE_CELL" in the Search/Replace tool.
    • My point is that this query it is very slow compared to my script. Since my script is also generic in the idea, I suspect there is some algorithmic difference (I don't know how you programmed the query, but there seems to be a big difference in the efficiency of the search).

    I propose you to try the example that I suggest and make up your own mind.
    Olivier

Sign In or Register to comment.