How to access every instance in a layout hierarchically ?

Hi folks,

Is there a function that gets every object/instance in a layout hierarchically ?

Pls note: i dont want CellView:Layout.each_cell(). I think i need the instance objects

But it would be nice to know how the similar function that must already exist, in its graphical form within the Cells Panel. Is that functional behind the panel exposed ?

Comments

  • https://www.klayout.de/forum/discussion/comment/10212#Comment_10212

    This thread is useful, but also doesn't provide the instance object.

  • Hello,

    What you need is: begin_instances_rec

    https://www.klayout.de/doc-qt5/code/class_Cell.html#method11

    Cheers,

    Tomas

  • Hi Tomas,

    Thanks for your input and patience to my belated response.

    I believe i wrote this post incorrectly. What i meant to say is access all objects not instances that in klayout refers to cells.

    I can access all instances (ie cells) with either layout.each_cell() or layout.top_cell().each_inst() fine. But these do NOT return shapes.

    Is there a function from a Layout Class or Cell Class that would returns all shape objects ?

    Best,
    Faisal

  • HI Faisal

    begin_shapes_rec returns all the shapes under cell, which requires a layer index as a parameter

    this layer index can be aquired by iterate through layer_infos.

    the begin_shapes_rec returns a recursive shape iter that holds shape, trans and hierarchical info.


    lv = pya.Application.instance().main_window().current_view() cv = lv.active_cellview() layout = cv.layout() cell = cv.cell for layer_info in layout.layer_infos(): layer_no = layer_info.layer layer_dt = layer_info.datatype layer_id = layout.layer(layer_no, layer_dt) for rsi in cell.begin_shapes_rec(layer_id): layer_id = rsi.layer() shape = rsi.shape() trans = rsi.dtrans() print (f"{layer_no}/{layer_dt}; {trans}; {shape};")

    Example layout

    the result of this layout is :


    1/0; r0 *1 0,0; polygon (-1500,-1500;-1500,1500;1500,-1500); 2/0; r0 *1 0,0; box (3500,-1500;6500,1500); # plan box object with coordinate in database unit 3/0; r0 *1 0,5; box (-1500,-1500;1500,1500); # plan box object in cell1 center is at cell-1 (0, 0), # ^^^^^^^^^ cell-1 is at (0, 5) 4/0; r0 *1 5,5; box (-1500,-1500;1500,1500); # << each individual array object from cell 2 4/0; r0 *1 5,8; box (-1500,-1500;1500,1500); 4/0; r0 *1 5,11; box (-1500,-1500;1500,1500); 4/0; r0 *1 8,5; box (-1500,-1500;1500,1500); 4/0; r0 *1 8,8; box (-1500,-1500;1500,1500); 4/0; r0 *1 8,11; box (-1500,-1500;1500,1500); 4/0; r0 *1 11,5; box (-1500,-1500;1500,1500); 4/0; r0 *1 11,8; box (-1500,-1500;1500,1500); 4/0; r0 *1 11,11; box (-1500,-1500;1500,1500);
Sign In or Register to comment.