set cellName "cellName"
set cellPtr [dbGet -p head.allCells.name $cellName]
if {$cellPtr == 0x0} {
Puts "ERROR: Cannot find a cell of name $cellName."
} else {
if {[dbGet selected.cell.allObstructions.layer.type overlap] == 0x0} {
#
# If the cell does not contain an obstruction on the overlap layer
# then calculate the area using the SIZE statement in the LEF.
#
set size [lindex [dbGet $cellPtr.size] 0]
set width [lindex $size 0]
set height [lindex $size 1]
set area [expr $width * $height]
Puts "Area of cell $cellName is $area."
} else {
#
# Else the cell contains obstructions on the overlap layer. Combine the obstructions
# and calculate their resulting area.
#
set overlapLayerObsPtr [dbGet -p2 selected.cell.allObstructions.layer.type overlap]
set totalShape {0 0 0 0}
foreach shape [dbGet $overlapLayerObsPtr.shapes.rect] {
Puts "rect: $shape"
set totalShape [dbShape $shape OR $totalShape -output rect]
}
set area 0
foreach rect $totalShape {
set area [expr $area + (([lindex $rect 2] - [lindex $rect 0]) * ([lindex $rect 3] - [lindex $rect 1]))]
}
Puts "Area of cell $cellName is $area based on overlap layer obstructions."
}
}