Convert cells to static (script)


In the API I am missing the function which is implemented in the GUI "layout/convert all cells to static". This is very handy to delete all links to libraries. The function "convert_cell_to_static" used on the top cell would not result in the same clean result for me.

Are these two functions doing the same, and if not, is the "convert all cells to static" available in the API?


  • Hi Martin,

    there is basically Instance#convert_to_static for instances and Layout#convert_cell_to_static for cells.

    The first function is the one that "Convert to static" from the Edit menu uses. The disadvantage is that it will create one cell for each instance.

    The second function will create a new cell representing the same - but static - layout of a PCell. This means you have to translate the instances yourself. The function will only create a new cell with the same layout than the PCell. The PCell instances will still point to the original PCell.



  • Hi Matthias

    Thank you for your help. I didn't figure out how to use the instances.
    creating a new instance works, but the cells I can not assign.
    I might misunderstand something. I want to assign the selected cell to the instance, which does not work the way I think it should.

    inst = pya.Instance()

    cell = pya.Application.instance().main_window().current_view().active_cellview().cell

    inst.cell = cell



  • Hi Martin,

    an "Instance" object can't live outside a Layout, so creating one with "pya.Instance()" is not the right way to use it.

    Where is the instance supposed to come from? Or what do you want to achieve in the end?


Sign In or Register to comment.