# Define the names of the two metals
set metal1 “M1”
set metal2 “M2”
# Get the coordinates of metal1’s bounding box
set metal1_bbox [get_bbox $metal1]
set metal1_xmin [lindex $metal1_bbox 0]
set metal1_ymin [lindex $metal1_bbox 1]
set metal1_xmax [lindex $metal1_bbox 2]
set metal1_ymax [lindex $metal1_bbox 3]
# Get the coordinates of metal2’s bounding box
set metal2_bbox [get_bbox $metal2]
set metal2_xmin [lindex $metal2_bbox 0]
set metal2_ymin [lindex $metal2_bbox 1]
set metal2_xmax [lindex $metal2_bbox 2]
set metal2_ymax [lindex $metal2_bbox 3]
# Calculate the overlap region
set overlap_xmin [max $metal1_xmin $metal2_xmin]
set overlap_ymin [max $metal1_ymin $metal2_ymin]
set overlap_xmax [min $metal1_xmax $metal2_xmax]
set overlap_ymax [min $metal1_ymax $metal2_ymax]
# Check if there is any overlap
if {$overlap_xmin < $overlap_xmax && $overlap_ymin < $overlap_ymax} {
# Calculate the width and height of the overlap region
set overlap_width [expr {$overlap_xmax – $overlap_xmin}]
set overlap_height [expr {$overlap_ymax – $overlap_ymin}]
# Print the coordinates and size of the overlap region
puts “Overlap region coordinates: ($overlap_xmin, $overlap_ymin) – ($overlap_xmax, $overlap_ymax)”
puts “Overlap region size: $overlap_width x $overlap_height”
} else {
puts “No overlap region found.”
}