Auto adjust net shape as below
##------------------------------------------------
## Create :Yanlong Wang
## Mail :snakekwang@gmail.com
## Blog :http://www.eetop.cn/blog/174222/spacelist-blog.html
## Tool :IC compiler
##------------------------------------------------
##Description : Adjust net shape T
##------------------------------------------------
set debug 0 foreach_in_collection e [get_selection] { set points [get_attribute $e points] set x0 [lindex [lindex $points 0] 0 ] set y0 [lindex [lindex $points 0] 1 ] set x1 [lindex [lindex $points 1] 0 ] set y1 [lindex [lindex $points 1] 1 ] set wire [get_object_name $e] set width [get_attribute $e width] if { $y0 == $y1 } { set h_w_x0 $x0 set h_w_y0 $y0 set h_w_x1 $x1 set h_w_y1 $y1 set h_w $wire set h_width $width set h_endcap $endcap set o_h_w_x0 $x0 set o_h_w_y0 $y0 set o_h_w_x1 $x1 set o_h_w_y1 $y1 set o_h_w $wireputs "$h_w $h_w_x0 $h_w_y0 $h_w_x1 $h_w_y1" } if { $x0 == $x1 } { set v_w_x0 $x0 set v_w_y0 $y0 set v_w_x1 $x1 set v_w_y1 $y1 set v_w $wire set v_width $width set v_endcap $endcap set o_v_w_x0 $x0 set o_v_w_y0 $y0 set o_v_w_x1 $x1 set o_v_w_y1 $y1 set o_v_w $wireputs "$v_w $v_w_x0 $v_w_y0 $v_w_x1 $v_w_y1" }}## cross point is $v_w_x0 $h_w_y0 set cross_x $v_w_x0set cross_y $h_w_y0
set h_left2cross [expr $cross_x - $h_w_x0]set h_cross2right [expr $h_w_x1 - $cross_x]set v_up2cross [expr $v_w_y1 - $cross_y]set v_cross2down [expr $cross_y - $v_w_y0]puts "h_left2cross =$h_left2cross"puts "h_cross2right =$h_cross2right"puts "v_up2cross = $v_up2cross "puts "v_cross2down = $v_cross2down"
if { ($h_left2cross < $h_cross2right ) && ($h_left2cross < $v_up2cross ) && ($h_left2cross < $v_cross2down ) } { if { $h_endcap == "square_ends" } { set h_w_x0 [expr $v_w_x0 - $v_width/2 ] } else { set h_w_x0 [expr $v_w_x0 - $v_width/2 + $h_width/2 ] }} elseif { ($h_cross2right < $h_left2cross ) && ($h_cross2right < $v_up2cross ) && ($h_cross2right < $v_cross2down ) } { if { $h_endcap == "square_ends" } { set h_w_x1 [expr $v_w_x0 + $v_width/2 ] } else { set h_w_x1 [expr $v_w_x0 + $v_width/2 - $h_width/2 ] }
} elseif { ($v_up2cross < $h_left2cross ) && ($v_up2cross < $h_cross2right ) && ($v_up2cross < $v_cross2down ) } {
if { $v_endcap == "square_ends" } {
set v_w_y1 [expr $h_w_y0 + $h_width/2]
} else {
set v_w_y1 [expr $h_w_y0 + $h_width/2 - $v_width/2]
}
} elseif { ($v_cross2down < $h_left2cross ) && ($v_cross2down < $h_cross2right ) && ($v_cross2down < $v_up2cross ) } {
if { $v_endcap == "square_ends" } {
set v_w_y0 [expr $h_w_y0 - $h_width/2]
} else {
set v_w_y0 [expr $h_w_y0 - $h_width/2 + $v_width/2]
}
}
puts "new :set_attribute $h_w points [list [list $h_w_x0 $h_w_y0] [list $h_w_x1 $h_w_y1] ]"
puts "new :set_attribute $v_w points [list [list $v_w_x0 $v_w_y0] [list $v_w_x1 $v_w_y1] ]"
if { $debug != 1 } {
set_attribute [get_net_shape $h_w ] points [list [list $h_w_x0 $h_w_y0] [list $h_w_x1 $h_w_y1] ]
set_attribute [get_net_shape $v_w ] points [list [list $v_w_x0 $v_w_y0] [list $v_w_x1 $v_w_y1] ]
}
puts "old:set_attribute $o_h_w points [list [list $o_h_w_x0 $o_h_w_y0] [list $o_h_w_x1 $o_h_w_y1] ]"
puts "old:set_attribute $o_v_w points [list [list $o_v_w_x0 $o_v_w_y0] [list $o_v_w_x1 $o_v_w_y1] ]"