Python code equivalent of converting all cells to static

edited October 2019 in Python scripting

Hi Matthias,

I am currently using the following code piece to convert all cells in a layout to static but it seems like it does not work properly. Do you think I am making a mistake in somewhere? I am trying to get the same effect as when I click Edit->Layout->Convert All Cells to Static.

Here is the code I use:


for cell in layout.each_cell():




  • Hello,

    The "convert_cell_to_static" method does not replace the cell - it will rather create a new, equivalent one. In order to replace all cells, you have first to create the static versions, then translate the instances and finally delete the original PCell variants:

    ly = cells_converted = {} # convert the cells for cell in ly.each_cell(): ci_org = cell.cell_index() ci = ly.convert_cell_to_static(ci_org) if ci != ci_org: cells_converted[ci_org] = ci # translate the instances for cell in ly.each_cell(): for inst in cell.each_inst(): if inst.cell_index in cells_converted: inst.cell_index = cells_converted[inst.cell_index] # delete the PCells for ci in cells_converted: ly.delete_cell(ci)



  • Thank you Matthias!

Sign In or Register to comment.