@REM 交点分割
@echo off
REM #jww
REM #cd
REM #ht10
REM #ht30
REM #zz
REM #zw
REM #c切断間隔(図寸)・・・無指定:1/_/a
REM #h2
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 交点分割2.rb temp.txt %1 > jwc_temp.txt
◎スクリプトファイル(ファイル名 交点分割2.rb)
def kouten(sen1,sen2)
include Math
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]
return [kouten_xt,kouten_yt]
end
end
end
def ika3(x)
a=(((x.to_f)*1000).to_i/1000.to_f)
return a
end
sen=[];by=[];zahyo=[];kankaku=1
while ARGV.size >1
case augument=ARGV.pop
when /\/a/
kankaku=augument[2..-1].to_f
end
end
while ARGF.gets
xy =split
if xy[0]=~/^hs/
xy[1..-1].each{|item|by< end
if xy[0]=~/^lg/
lg=xy[0][2,1]
zusun=by[lg.hex]
end
if xy[0]=~/^[0-9]/ or xy[0]=~ /^-/
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2]=xy[2],xy[0]
xy[1],xy[3]=xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
sen << (xy)
end
end
puts"hd"
m=0
open("temp.txt","r"){|f|
while line=f.gets
m += 1
xy=line.split
if xy[0]=~/^hq/
elsif xy[0]=~/^z/
print line
zno=m
z=xy[0]
elsif xy[0]=~/^[0-9]/ or xy[0]=~ /^-/
if zno
m==zno+1 ? zokusei=z : zokusei=""
end
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2]=xy[2],xy[0]
xy[1],xy[3]=xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
x=xy[2]-xy[0]
y=xy[3]-xy[1]
xyl=Math.sqrt(x**2+y**2)
dx=x/xyl
dy=y/xyl
zahyo=[]
sen.shift
sen.each{|item1|
if kouten(item1,xy) != nil
zahyo << kouten(item1,xy)
end
}
if zahyo.size==0
print line
elsif zahyo.size==1
printf("%10f %10f %10f %10f \n",
xy[0],xy[1],
zahyo[0][0]-kankaku*zusun*dx,
zahyo[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",
xy[2],xy[3],
zahyo[0][0]+kankaku*zusun*dx,
zahyo[0][1]+kankaku*zusun*dy)
else
if xy[0]==xy[2]
zahyo1=zahyo.sort{|a,b| a[1]<=>b[1]}
else
zahyo1=zahyo.sort{|a,b| a[0]<=>b[0]}
end
printf("%10f %10f %10f %10f \n",xy[0],xy[1],zahyo1[0][0]-kankaku*zusun*dx,zahyo1[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",xy[2],xy[3],zahyo1[-1][0]+kankaku*zusun*dx,zahyo1[-1][1]+kankaku*zusun*dy)
n=0
while n unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",zahyo1[n][0]+kankaku*zusun*dx,zahyo1[n][1]+kankaku*zusun*dy,zahyo1[n+1][0]-kankaku*zusun*dx,zahyo1[n+1][1]-kankaku*zusun*dy)
n+=1
end
end
else
print line
end
end
}
@REM 連続線の記入と交差線の切断
@echo off
REM #jww
REM #cd
REM #h4
REM #ht10
REM #ht30
REM #zz
REM #zw
REM #cR面取寸法 無指定:200/_/a
REM #c切断間隔(図寸) 無指定:1 /_/b
REM #1/基準点を指示 Free(L) Read(R) 左AM1:00方向ドラッグで15度切替
REM #99#
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 連線記入.rb temp.txt %1 %2> jwc_temp.txt
◎スクリプトファイル(ファイル名 連線記入.rb)
include Math
require "交点.rb"
$by=200;kankaku=1
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
$by=argument[2..-1].to_f
when /\/b/
kankaku=argument[2..-1].to_f
end
end
by=[];$hp=[]
while ARGF.gets
xy =split
if xy[0]=~/^hs/
xy[1..-1].each{|item|by< end
if xy[0]=~/^lg/
lg=xy[0][2,1]
zusun=by[lg.hex]
end
if xy[0] =~ /^hp/
$hp<<[xy[1].to_f,xy[2].to_f]
end
end
sen=[]
0.upto($hp.size-2){|i|sen<<[$hp[i],$hp[i+1]].flatten}
puts"hd"
m=0
open("temp.txt","r"){|f|
while line=f.gets
m += 1
xy=line.split
if xy[0]=~/^hq/
elsif xy[0]=~/^z/
print line
zno=m
z=xy[0]
elsif xy[0]=~/^[0-9]/ or xy[0]=~ /^-/
if zno
m==zno+1 ? zokusei=z : zokusei=""
end
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2]=xy[2],xy[0]
xy[1],xy[3]=xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
x=xy[2]-xy[0]
y=xy[3]-xy[1]
xyl=Math.sqrt(x**2+y**2)
dx=x/xyl
dy=y/xyl
zahyo=[]
sen.each{|item1|
if sen_kouten(item1,xy) != nil
zahyo << sen_kouten(item1,xy)
end
}
if zahyo.size==0
print line
elsif zahyo.size==1
printf("%10f %10f %10f %10f \n",
xy[0],xy[1],
zahyo[0][0]-kankaku*zusun*dx,
zahyo[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",
xy[2],xy[3],
zahyo[0][0]+kankaku*zusun*dx,
zahyo[0][1]+kankaku*zusun*dy)
else
if xy[0]==xy[2]
zahyo1=zahyo.sort{|a,b| a[1]<=>b[1]}
else
zahyo1=zahyo.sort{|a,b| a[0]<=>b[0]}
end
printf("%10f %10f %10f %10f \n",xy[0],xy[1],zahyo1[0][0]-kankaku*zusun*dx,zahyo1[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",xy[2],xy[3],zahyo1[-1][0]+kankaku*zusun*dx,zahyo1[-1][1]+kankaku*zusun*dy)
n=0
while n unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",zahyo1[n][0]+kankaku*zusun*dx,zahyo1[n][1]+kankaku*zusun*dy,zahyo1[n+1][0]-kankaku*zusun*dx,zahyo1[n+1][1]-kankaku*zusun*dy)
n+=1
end
end
else
print line
end
end
}
def kouten(sen1,sen2)
include Math
sen1.collect!{|item|item.to_f}
sen2.collect!{|item|item.to_f}
if sen1[0]>sen1[2]
sen1[0],sen1[2]=sen1[2],sen1[0]
sen1[1],sen1[3]=sen1[3],sen1[1]
elsif sen1[0]==sen1[2]
if sen1[1]>sen1[3]
sen1[1],sen1[3]=sen1[3],sen1[1]
end
end
if sen2[0]>sen2[2]
sen2[0],sen2[2]=sen2[2],sen2[0]
sen2[1],sen2[3]=sen2[3],sen2[1]
elsif sen2[0]==sen2[2]
if sen2[1]>sen2[3]
sen2[1],sen2[3]=sen2[3],sen2[1]
end
end
return kakudo
end
def sen_kouten(sen1,sen2)
include Math
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]
return [kouten_xt,kouten_yt]
end
end
end
def ika3(x)
a=(((x.to_f)*1000).to_i/1000.to_f)
return a
end
#線の長さを返す(mm)
def nagasa(zahyo)
include Math
zahyo.to_a
x=zahyo[2]-zahyo[0]
y=zahyo[3]-zahyo[1]
l=sqrt(x**2+y**2)