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]
set endcap [get_attribute $e endcap]
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 $wire
puts "$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 $wire
puts "$v_w $v_w_x0 $v_w_y0 $v_w_x1 $v_w_y1"
}
}
if { [expr $h_w_x1 - $v_w_x0] < [expr $v_w_x0 - $h_w_x0] } {
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 ]
}
} else {
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 ]
}
}
if { [expr $v_w_y1 - $h_w_y0] < [expr $h_w_y0 - $v_w_y0] } {
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]
}
} else {
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] ]"
if { $debug != 1 } {
#set_attribute [get_net_shape $o_h_w ] points [list [list $o_h_w_x0 $o_h_w_y0] [list $o_h_w_x1 $o_h_w_y1] ]
#set_attribute [get_net_shape $o_v_w ] points [list [list $o_v_w_x0 $o_v_w_y0] [list $o_v_w_x1 $o_v_w_y1] ]
}