Export the coordinations of each instances

edited February 2012 in General
Hi Matthias,

I've been using klayout for about a year, great software, awesome supports.

Currently, as project required, I'll need to get the coordination of each instances.
However, as I'm still unfamiliar with Ruby programming, I can only export the bbox of the instances, but not the true coordinate with respect to the top cell.

Please helps. Thanks a lot :)
Best regards, leeth


  • edited February 2012

    Hi leeth,

    there is a sample script in the "Useful ruby scripts" section which does a similar thing, namely dumping shapes as they would appear in the top cell: http://www.klayout.de/useful_scripts.html#dump_flat_shapes.rbm.

    It can be modified to dump instances as well.

    If you replace this section:

    cell.shapes(layer).each do |shape|
      if shape.is_box?
        box = shape.box.transformed_cplx(itrans)
        file.puts("    <box>#{box.to_s}</box>")
      elsif shape.is_path?
        path = shape.path.transformed_cplx(itrans)
        file.puts("    <path>#{path.to_s}</path>")
      elsif shape.is_polygon?
        polygon = shape.polygon.transformed_cplx(itrans)
        file.puts("    <polygon>#{polygon.to_s}</polygon>")
      elsif shape.is_text?
        text = shape.text.transformed_cplx(itrans)
        file.puts("    <text>#{text.to_s}</text>")

    with something like that:

    name = layout.cell_name(cell.cell_index)
    file.puts("    <cell>#{name}: #{itrans.to_s}</cell>")

    it will print the transformation (shift vector, angle and mirror flag) and the name of the cell instantiated. The transformation tells how the child cell appears in the top cell.

    Of course that is just a suggestion. The output format can be adjusted and the functions should be renamed to reflect the new meaning.

    Best regards,


Sign In or Register to comment.