I started a script to replace dedicated cells out of a selection.
This works fine so far but I'm struggling with an offset.
After replacement all cell are placed cell length + 0.5 and cell width + 0.5.
I run already an adjust origin but this doesn't help. I would like to use for the replacement cells the same origin as for the original one. Any idea is highly appreciated.
#---
app = RBA::Application.instance
mw = app.main_window
lv = mw.current_view
if lv == nil
raise "Flatten: No view selected"
end
lv.transaction("Replace cell")
lv.each_object_selected do |sel|
cv = lv.cellview( sel.cv_index )
target = cv.cell
ly = cv.layout
source = cv.layout.cell( sel.cell_index )
# CHANGE CELL NAMES HERE!!!
cell_to_replace = ly.cell("CIRCUIT")
new_cell = ly.cell("toto")
inst_to_replace = []
if cell_to_replace.cell_index == sel.cell_index
inst_to_replace << sel.inst
end
inst_to_replace.each { |ci| ci.cell_index = new_cell.cell_index }
#end lv.each forach sel ...
end
lv.commit
#----
Comments
Hi Andy,
is the origin (0,0) of the replacement cell the same than that of the original cell?
A cell placement puts the origin of a cell at the specified position. If for example, the original cell had it's origin in the center while the new cell is drawn such that the origin is at the lower-left corner the effect will be the one you described.
The choice of the cell origin is important and often the origin carries a notion of being some kind of "reference point". For example, the origin may designate the lower-left corner of the logical extensions of a standard cell. The physical extensions might be different from that because some layers are drawn bigger to provide overlap with neighbour cells.
If you need to migrate cells to a library with a different convention then I'd suggest to first adjust the origin of the replacement cells to the conventions of the original cells (for example by using "Adjust Origin" and then to replace the instances.
Matthias
Works for me - Thanks a lot Matthias.