# 1) 选中所有 Macro
select_obj [dbGet top.insts.cell.subClass block -p2]
# 2) 只导出当前选中对象的 DEF(文件名按项目改)
defOut -selected ../data/macro_place.def
# 3) 注释掉 DEF 头部 PROPERTYDEFINITIONS 与 DIEAREA,避免把本设计 die/core 属性带给对方
# 用法: comment_def_header_for_share ../data/macro_place.def
proc comment_def_header_for_share {def_file} {
set fp [open $def_file r]
set lines [split [read $fp] "\n"]
close $fp
set out {}
set in_prop 0
set in_die 0
foreach line $lines {
set t [string trim $line]
if {[string match "PROPERTYDEFINITIONS*" $t]} {
set in_prop 1
}
if {$in_die == 0 && [string match "DIEAREA*" $t]} {
set in_die 1
}
if {$in_prop || $in_die} {
if {[string match "#*" $t]} {
lappend out $line
} else {
lappend out "#$line"
}
} else {
lappend out $line
}
if {$in_prop && [string match "END PROPERTYDEFINITIONS*" $t]} {
set in_prop 0
}
if {$in_die && [string match "*;" $t]} {
set in_die 0
}
}
set fp [open $def_file w]
puts $fp [join $out "\n"]
close $fp
puts "Commented PROPERTYDEFINITIONS + DIEAREA in $def_file"
}
comment_def_header_for_share ../data/macro_place.def