It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I am trying the following custom queries to replace 'SUB1' instances with the 'SUB2' instances only if it is located in the left x-axis. It does not show any error but it also does not replace the instance. Also, can I also do these queries in the macro python script, if so can you please let me know how.
Thanks
with instances of cell Main.* where (cell.bbox.left==-70000 && cell.bbox.right==0 && cell_name ~ "SUB1") do inst.cell_index = <<"SUB2">>
Comments
The query needs to use "inst" instead of "cell" for the coordinate check.
Here is a sample for a test case of mine. Please also note I'm using "dbbox" which is like "bbox", but returns the micron-unit bounding box (instead of DBU):
You can run a query through the LayoutQuery class (see https://www.klayout.de/doc-qt5/code/class_LayoutQuery.html) in Python. However, I think it's easier and safer to directly code the query as a Python loop over the instances inside the cell.
Matthias
Hi Matthias,
Thank you so much. In the meantime, I figured out how to do it with python scripting -
Very good
BTW: the lengthy second line can be simplified to:
Regards,
Matthias
@Matthias
Could you please help to check how to do "replace" in Ruby?
I knew that some explain in your document.
Signature: Instance replace (const Instance instance, const CellInstArray cell_inst_array)
But that code below is not workable...
instance.replace(RBA::CellInstArray::new(placeme, RBA::Trans::new(RBA::Vector::new(0, 0))))
here was my full code.