Fetch all Instance of a cell

edited March 24 in Python scripting

@Matthias I need to fetch all instance of a cell, similar to Browse instance in python script. Any help on how to proceed with that?



  • edited March 24
     def get_path(l1,path=None):
            if l1.is_top():
            for p in l1.each_parent_inst():
                    p_inst = p.inst()
                    aref = ""
                        aref = "[{},{}]".format(p_inst.na,p_inst.nb)
                        aref= "(+{}x)".format(p_inst.size() - 1)
                    new_path = ""
                    if path:
                        new_path = layout.cell_name(p.parent_cell_index()) + aref + "/"+ path
                        new_path = layout.cell_name(p.parent_cell_index()) + aref + "/"
                    cell = layout.cell(p.parent_cell_index())

    I figured it out! But what's difference between regular array and instance.size>1? (i.e which instance would not be captured by regular array)

    the definition for complex array is it has magnification or arbitary rotation. This has magnification but it is captured by regular array. Can you please tell what's the difference?


  • edited March 31

    @vandhana Sorry for the late reply ... and very good your figured it out :) The code will give you the instantiation paths of a specific cell. That's pretty much how the instance browser does it - very good! :)

    The mystery about the size() > 1 instance is twofold: first, a regular array in a special case can have size () == 1, so size () > 1 tells you the instance is actually a "multi-instance". Second, in some cases you may find something which is called "iterated instances". You cannot create such instanced with the editor nor can you see them. But they are present in viewer mode inside the database and when you read certain kind of OASIS files. "iterated instances" are basically instances which come with a list of coordinates rather than array dimensions and step vectors. OASIS uses such instances for compactness and KLayout keeps this representation to reduce the memory footprint for big OASIS files.

    Hence - and only in these cases - you may see instances which are not regular, but have size > 1. You can iterate the members of this iterated instance with "each_trans" or "each_cplx_trans" if you're interested.

    Kind regards,


  • @Matthias
    Thanks for your insights. It's of great help. :)

Sign In or Register to comment.