REM 10の位以下を四捨五入
echo off
REM #jww
REM #cd
REM #zz
REM #h3
REM #hc文字を範囲選択してください
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 00$.rb temp.txt > jwc_temp.txt
◎スクリプトファイル(ファイル名 00$.rb)
BEGIN{
puts "hd"
}
def main
hash={"0"=>"0","1"=>"1","2"=>"2","3"=>"3","4"=>"4",
"5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9"," "=>" ","."=>"."}
hash1=hash.invert
while ARGF.gets
xy =split
if xy[0] =="hq"
elsif xy[0] =~/^cs/ or xy[0] =~/^ch/
a=$_.split("\"")
tango1=(a[1].chop).delete("\s")
tango2=tango1.delete(" ")
tango3=tango2.split('')
if tango3[0].size==1
word=tango2
else
tango=tango3.collect{|item| hash1[item]}
word=tango.join('')
end
if word=~/^[0-9]/ && word=~/[0-9]$/
x=xy[1].to_f
y=xy[2].to_f
mojix=xy[3].to_f
mojiy=xy[4].to_f
word2=((((word.to_f)/100).round)*100).to_s
if tango3[0].size==1
sunpou=(comma(word2).gsub("\,","\s"))
else
tango4=((comma(word2)).gsub(
"\,","\s")).split('')
tango5=tango4.collect{|item|hash[item]}
sunpou=tango5.join('')
end
printf("ch %.10f %.10f %.10f %.10f \"%s\n",
x,y,mojix,mojiy,sunpou)
else
print $_
end
else
print $_
end
end
end
def comma(s)
r = [/(\d\d\d)((?=\d))/,/(\d)(\d\d)/,/(\d\d)(\d)/] [s.size % 3]
s.gsub!(r,'\1,\2')
end
main
BEGIN{
puts "hd"
}
def main
hash={"0"=>"0","1"=>"1","2"=>"2","3"=>"3","4"=>"4",
"5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9","\s"=>" ","."=>"."}
hash1=hash.invert
while ARGF.gets
xy =split
if xy[0] =="hq"
elsif xy[0] =~/^cs/ or xy[0] =~/^ch/
a=$_.split("\"")
tango1=(a[1].chop).delete("\s")
tango2=tango1.delete(" ")
tango3=tango2.split('')
if tango3[0].size==1
word=tango2
else
tango=tango3.collect{|item| hash1[item]}
word=tango.join('')
end
if word=~/^[0-9]/ && word=~/[0-9]$/
x=xy[1].to_f
y=xy[2].to_f
mojix=xy[3].to_f
mojiy=xy[4].to_f
word2=((((word.to_f)/100).round)*100).to_s
worda=word2.split('')
if tango3[0].size==1
if worda.size>3
sunpou=(comma(word2).gsub("\,",
"\s"))
else
sunpou=word2
end
else
if worda.size>3
tango4=((comma(word2)).gsub(
"\,","\s")).split('')
else
tango4=word2.split('')
end
tango5=tango4.collect{|item|hash[item]}
sunpou=tango5.join('')
end
printf("ch %.10f %.10f %.10f %.10f \"%s\n",
x,y,mojix,mojiy,sunpou)
else
print $_
end
else
print $_
end
end
end
def comma(s)
r = [/(\d\d\d)((?=\d))/,/(\d)(\d\d)/,/(\d\d)(\d)/] [s.size % 3]
s.gsub!(r,'\1,\2')
end
main
REM 10の位以下を四捨五入
echo off
REM #jww
REM #cd
REM #zz
REM #h3
REM #hc文字を範囲選択してください
REM #k3桁ごとの区切文字 無指定= 1)|1)コンマ(L)|2)スペース(R)| /_/a
REM #k数値を丸める桁数(四捨五入) 無指定= 1)|1)無(L)|2)下1桁(R)|3)下2桁|4)下3桁| /_/b
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 00$.rb temp.txt %1 %2 > jwc_temp.txt
◎スクリプトファイル(00$.rb)
BEGIN{
puts "hd"
$kugiri="1"
$keta="1"
while ARGV.length > 1
case argument=ARGV.pop
when/^\/a/
$kugiri=argument[2..-1]
when/^\/b/
$keta=argument[2..-1]
end
end
}
def main
if $keta=="1";keta=1;elsif $keta=="2";keta=10;elsif $keta=="3";keta=100
elsif $keta=="4";keta=1000
end
hash={"0"=>"0","1"=>"1","2"=>"2","3"=>"3","4"=>"4",
"5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9",
","=>",","\s"=>" ","."=>"."}
hash1=hash.invert
while ARGF.gets
xy =split
if xy[0] =="hq"
elsif xy[0] =~/^cs/ or xy[0] =~/^ch/
a=$_.split("\"")
tango1=a[1].chop
tango2=tango1.tr(" ,,","")
tango3=tango2.split('')
if tango3[0].size==1
tango=tango3
word=tango2
else
tango=tango3.collect{|item| hash1[item]}
word=tango.join('')
end
if word=~/^[0-9]/ && word=~/[0-9]$/ &&
tango.include?(nil)!=true
x=xy[1].to_f
y=xy[2].to_f
mojix=xy[3].to_f
mojiy=xy[4].to_f
word2=((((word.to_f)/keta).round)*keta).to_s
worda=word2.split('')
if tango3[0].size==1
if worda.size>3
if $kugiri=="1"
sunpou=comma(word2)
elsif $kugiri=="2"
sunpou=(comma(word2).gsub("\,","\s"))
end
else
sunpou=word2
end
else
if worda.size>3
if $kugiri=="1"
tango4=comma(word2).split('')
elsif $kugiri=="2"
tango4=((comma(word2)).gsub("\,","\s")).split('')
end
else
tango4=word2.split('')
end
tango5=tango4.collect{|item|hash[item]}
sunpou=tango5.join('')
end
printf("ch %s %s %s %s \"%s\n",
x,y,mojix,mojiy,sunpou)
else
print $_
end
else
print $_
end
end
end
def comma(s)
r = [/(\d\d\d)((?=\d))/,/(\d)(\d\d)/,/(\d\d)(\d)/] [s.size % 3]
s.gsub!(r,'\1,\2')
end
main
@REM 線の長さを記入する(mm)
@echo off
REM #jww
REM #cd
REM #c 書込文字種の指定 無指定:文字種2 /_/a
REM #c 文字と線の離れ(図寸)無指定= 1mm /_/b
REM #k 無指定= 1)|1)半角(L)|2)全角(R)| /_/c
REM #k3桁ごとの区切文字 無指定= 1)|1)コンマ(L)|2)スペース(R)| /_/d
REM #k数値を丸める桁数(四捨五入) 無指定= 1)|1)無(L)|2)下1桁(R)|3)下2桁|4)下3桁| /_/e
REM #h1
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 線長記入.rb temp.txt %1 %2 %3 %4 %5> jwc_temp.txt
◎スクリプトファイル(ファイル名 線長記入.rb)
BEGIN{
$moji="2"
$hanare=1
$han_zen="1"
$kugiri="1"
$keta="1"
while ARGV.length > 1
case argument=ARGV.pop
when/^\/a/
$moji=argument[2..-1]
when/^\/b/
$hanare=argument[2..-1].to_f
when/^\/c/
$han_zen=argument[2..-1]
when/^\/d/
$kugiri=argument[2..-1]
when/^\/e/
$keta=argument[2..-1]
end
end
}
def main
hash={"0"=>"0","1"=>"1","2"=>"2","3"=>"3","4"=>"4",
"5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9","\s"=>" ","."=>"."}
by=[]
puts "cn"+$moji
puts "cc1"
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[1],xy[3]=xy[2],xy[0],xy[3],xy[1]
end
if xy[0] == xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
xx=xy[2]-xy[0]
yy=xy[3]-xy[1]
$xy=Math.sqrt(xx**2+yy**2)
dx=xx/$xy
dy=yy/$xy
if $keta=="1";keta=1;elsif $keta=="2";keta=10
elsif $keta=="3";keta=100;elsif $keta=="4";keta=1000
end
word=((($xy/keta).round)*keta).to_s
if $kugiri=="1"
word1=comma(word)
else
word1=(comma(word)).gsub("\,","\s")
end
if $han_zen=="2"
a=word1.split('')
a.collect!{|item|hash[item]}
word2=a.join('')
else
word2=word1
end
puts "z3"
printf("ch %f %f %f %f \"%s\n",
xy[0]+xx/2-$hanare*zusun*dy,
xy[1]+yy/2+$hanare*zusun*dx,dx,dy,word2)
end
end
end
def comma(s)
r = [/(\d\d\d)((?=\d))/,/(\d)(\d\d)/,/(\d\d)(\d)/] [s.size % 3]
s.gsub!(r,'\1,\2')
end
main()
BEGIN{
$moji="2"
$hanare=1
$han_zen="1"
$kugiri="1"
$keta="1"
while ARGV.length > 1
case argument=ARGV.pop
when/^\/a/
$moji=argument[2..-1]
when/^\/b/
$hanare=argument[2..-1].to_f
when/^\/c/
$han_zen=argument[2..-1]
when/^\/d/
$kugiri=argument[2..-1]
when/^\/e/
$keta=argument[2..-1]
end
end
}
def main
hash={"0"=>"0","1"=>"1","2"=>"2","3"=>"3","4"=>"4",
"5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9",
","=>",","\s"=>" ","."=>"."}
by=[]
puts "cn"+$moji
puts "cc1"
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[1],xy[3]=xy[2],xy[0],xy[3],xy[1]
end
if xy[0] == xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
xx=xy[2]-xy[0]
yy=xy[3]-xy[1]
$xy=Math.sqrt(xx**2+yy**2)
dx=xx/$xy
dy=yy/$xy
if $keta=="1";keta=1;elsif $keta=="2";keta=10
elsif $keta=="3";keta=100;elsif $keta=="4";keta=1000
end
word=((($xy/keta).round)*keta).to_s
if word.size>3
if $kugiri=="1"
word1=comma(word)
else
word1=(comma(word)).gsub("\,","\s")
end
else
word1=word
end
if $han_zen=="2"
a=word1.split('')
a.collect!{|item|hash[item]}
word2=a.join('')
else
word2=word1
end
puts "z3"
printf("ch %f %f %f %f \"%s\n",
xy[0]+xx/2-$hanare*zusun*dy,
xy[1]+yy/2+$hanare*zusun*dx,dx,dy,word2)
end
end
end
def comma(s)
r = [/(\d\d\d)((?=\d))/,/(\d)(\d\d)/,/(\d\d)(\d)/] [s.size % 3]
s.gsub!(r,'\1,\2')
end
main()