It's quite simple to do using the method "is_empty":
module MyMacro
include RBA
layout = Application.instance.main_window.current_view.active_cellview.layout
empty_cell_count = 1
layout.each_cell do |cell|
if cell.is_empty
puts "#{empty_cell_count}: Cell \"#{cell.name}\" is empty..."
empty_cell_count += 1
end # if
end # each_cell
if empty_cell_count == 1
puts "No empty cells found..."
end # if
end # MyMacro
I personal prefer the definition of "emptiness" in a geometrical sense. I often use cell.bbox().is_empty() to check if a cell is empty.
It's a matter of application I assume. A cell that calls empty child cells isn't empty in the sense of not having any objects, but empty in the sense being void of geometry. The bbox approach checks for emptiness in the geometrical sense. I find this definition more useful in many applications, but of course that is not necessarily true for others.
Comments
Hi,
It's quite simple to do using the method "is_empty":
Cheers,
Tomas
@dbeaster in addition to code presented please check the docs about Cell object:
https://www.klayout.de/doc-qt5/code/class_Cell.html#method81
Despite that the example above is Ruby based, the Python version will be the same
Thanks for this discussion.
I personal prefer the definition of "emptiness" in a geometrical sense. I often use
cell.bbox().is_empty()
to check if a cell is empty.It's a matter of application I assume. A cell that calls empty child cells isn't empty in the sense of not having any objects, but empty in the sense being void of geometry. The bbox approach checks for emptiness in the geometrical sense. I find this definition more useful in many applications, but of course that is not necessarily true for others.
Matthias
Hi Matthias,
Thanks for the tip! Makes more sense to me as well. Should be
cell.bbox().empty()
.Cheers,
Tomas
You're right. I can no longer edit the text above