How to get the rotation (orientation) of the cell instantiated through pya.CellInstArray

Hi Everyone.

I am writing a Python script for Klayout.

In the script I have selected a box.
I need to be able to identify the rotation (orientation) of the parent cell containing the selected box, when this parent cell had been instantiated as one of an array of cells.

BOX -> Parent Cell -> Parent is part of a CellInstancesArray -> CellInstancesArray.rotation

I know this information is stored somewhere, but I can't find it.

Can you please give some suggestion?

Thank you in advance
Best regards


  • Hi Giovanni,

    here is some code which demonstrates how to use the "ObjectInstPath" object you're looking for:

    # Gets the current layout view lv = pya.LayoutView.current() for object_path in lv.each_object_selected(): # We are looking for selected *shapes*, not instances: if not object_path.is_cell_inst(): ly = lv.cellview(object_path.cv_index).layout() # The "source cell" is the cell the shape resides in. source_cell = ly.cell(object_path.source()) # The "top cell" is the current top cell shown in the layout panel. top_cell = ly.cell( # Trans is the accumulated transformation applied to the shape # when it appears in the top cell. "source_dtrans" will give the # transformation in micrometer units while "source_trans" (without # "d") gives it in DBU units. # NOTE: trans.angle() will give you the rotation angle. # See "CplxTrans" documentation for more attributes. trans = object_path.source_dtrans() # Takes the (micrometer unit) bounding box of the shape bbox = object_path.shape.dbox print("Object: " + str(bbox) + " in cell " + + ", seen at " + str(trans) + " from " +


  • Thank you Matthias, it work perfect :)

  • edited October 2020

    thank you. is working now :-)

Sign In or Register to comment.