| 外部変形ならば、以下をコピペしてください。 (ruby の動作環境が必要) 所要時間は、標準機能(一括切断後、線種一括変更)と大差ありません。
◎バッチファイル(ファイル名 交点線種変更.bat)
@REM 線交点以降の線種一括変更 @echo off REM #jww REM #cd REM #ht10 REM #ht30 REM #ht40 REM #zz REM #zw REM #zc REM #c変更後の線種 無指定:2/_/a REM #h2 REM #hc対象線を選択してください REM #1ln基準線を指示してください free(L) Read(R) REM #2基準線のどちら側を線種変更しますか? 方向を指定してください REM #hp REM #e copy jwc_temp.txt temp.txt > nul ruby -Ks 交点線種変更.rb temp.txt %1 > jwc_temp.txt
◎スクリプトファイル(ファイル名 交点線種変更.rb)
include Math def sen_sen_kouten(sen1,sen2) sen1x=sen1[2]-sen1[0] sen1y=sen1[3]-sen1[1] sen1xy=sqrt(sen1x**2+sen1y**2) sen1_arg=atan2(sen1y,sen1x) x1_1=sen1[0] x1_2=sen1[0]+sen1xy y1_1=sen1[1] y1_2=sen1[1]
x=sen2[0]-sen1[0] y=sen2[1]-sen1[1] xy=sqrt(x**2+y**2) arg=atan2(y,x) henkaku=arg-sen1_arg x2_1=sen1[0]+xy*cos(henkaku) y2_1=sen1[1]+xy*sin(henkaku)
x=sen2[2]-sen1[0] y=sen2[3]-sen1[1] xy=sqrt(x**2+y**2) arg=atan2(y,x) henkaku=arg-sen1_arg x2_2=sen1[0]+xy*cos(henkaku) y2_2=sen1[1]+xy*sin(henkaku)
x=x2_2-x2_1 y=y2_2-y2_1 delta=y/x
if ika3(y2_1)>=ika3(y1_1) && ika3(y2_2) ika3(y2_1) ika3(y2_2)>=ika3(y1_1)
y=y1_1-y2_1 dx=y/delta kouten_x=x2_1+dx kouten_y=y1_1
if kouten_x>=x1_1 && kouten_xx1_1 && kouten_x<=x1_2 x=kouten_x-x1_1 y=kouten_y-y1_1 xy=sqrt(x**2+y**2) kouten_xt=x1_1+xy*cos(sen1_arg) kouten_yt=y1_1+xy*sin(sen1_arg)
return [kouten_xt,kouten_yt] else nil end else nil end end def ika3(x) a=(((x.to_f)*1000).to_i/1000.to_f)
return a end
lt1="lt2"
while ARGV.size>1 case argument=ARGV.pop when /\/a/ lt1="lt"+argument[2..-1] end end
while ARGF.gets xy=split if xy[0]=~/^hp2/ hpx=xy[1].to_f hpy=xy[2].to_f end
if xy[0]=~/^hhp1ln/ line=ARGF.gets sen=line.split sen.collect!{|item|item.to_f} end end
puts "hd" open("temp.txt","r"){|f| while line=f.gets xy=split if xy[0] =~ /^hq/ elsif xy[0] =~/^lt/ lt0=xy[0] elsif xy[0] =~/^hhp1ln/ puts lt0 print line ln=f.gets print ln elsif xy[0] =~/^\d/ xy.collect!{|item|item.to_f} kouten=sen_sen_kouten(sen,xy)
if kouten != nil x=hpx-xy[0] y=hpy-xy[1] l=sqrt(x**2+y**2) arg=atan2(y,x) xy_x=xy[2]-xy[0] xy_y=xy[3]-xy[1]
xy_arg=atan2(xy_y,xy_x) henkaku=arg-xy_arg tenx=xy[0]+l*cos(henkaku)*cos(xy_arg) teny=xy[1]+l*cos(henkaku)*sin(xy_arg) x1=tenx-xy[0] y1=teny-xy[1] l1=sqrt(x1**2+y1**2)
x2=kouten[0]-xy[0] y2=kouten[1]-xy[1] l2=sqrt(x2**2+y2**2)
if l1 puts lt1 puts [xy[0],xy[1],kouten[0],kouten[1]].join("\s") puts lt0 puts [kouten[0],kouten[1],xy[2],xy[3]].join("\s") else puts lt0 puts [xy[0],xy[1],kouten[0],kouten[1]].join("\s") puts lt1 puts [kouten[0],kouten[1],xy[2],xy[3]].join("\s") end else print line end else print line end end }
|