円中心線(改)
円・楕円に中心線を作図する外部変形です。
以前公開した、円中心線 を、jscriptで再作成しました。
比率、線色/線種は、バッチファイルのユーザー設定で指定してください。
@if(0==1) //円中心線
@echo off
REM #jww
REM #cd
REM #h2 範囲内・範囲内外の図形選択
REM #hc 範囲選択してください
REM #e
cscript //nologo //e:jscript "%~f0" %*
copy temp.txt jwc_temp.txt
del temp.txt
goto:eof
@end
/////
fs=new ActiveXObject( "Scripting.FileSystemObject" )
r=fs.OpenTextFile("jwc_temp.txt")
w=fs.CreateTextFile("temp.txt")
//ユーザー設定
rto=1.2 //比率
lc="lc4" //線色
lt="lt5" //線種
//初期設定
sp=" " //スペース
dq="\"" //ダブルコーテーション
i=0;j=0;k=0;m=0 //カウンタ
//配列
x=[];y=[];rad=[]
xl=[];xr=[];yu=[];yl=[];
//テキストデータ読込み
while (!r.AtEndOfLine){
line=r.ReadLine()
if(/hq/.test(line)){}
//
else if(/#/.test(line)){i=1
w.WriteLine(line)}
//円データ取得
else if(/ci/.test(line)){
xy=line.split(/\s+/)
num=xy.length
xc=Number(xy[1]);yc=Number(xy[2])
rad=Number(xy[3])
ths=Number(xy[4]);the=Number(xy[5])
per=Number(xy[6])
if(num==8 && ths!=the){m=1} //円弧、楕円弧
else{m=0
xl[j]=xc-rto*rad;xr[j]=xc+rto*rad
x[j]=xc;y[j]=yc
if(num==8 && per!=1){ //楕円
yu[j]=yc+rto*per*rad
yl[j]=yc-rto*per*rad}
else{ //円
yu[j]=yc+rto*rad
yl[j]=yc-rto*rad}}
if(m==1){}else{ j=j+1}}
else{ if(i==1){}
else{ w.WriteLine(line)}}}
//線色・線種指定
w.WriteLine(lc)
w.WriteLine(lt)
//中心線作図
for(k=0;k<j;k++){
hctr=[xl[k],y[k],xr[k],y[k]] //水平線
hctr=hctr.join(sp)
vctr=[x[k],yu[k],x[k],yl[k]] //垂直線
vctr=vctr.join(sp)
w.WriteLine(hctr)
w.WriteLine(vctr)}
w.Close();r.Close()
| 固定リンク
コメント