文字矩形枠2
文字矩形枠のバッチファイルを矩形枠専用にしました。
・対象文字は、横文字(水平/垂直/任意角)
・補助線色/線種で矩形枠を作図
・全レイヤグループに適用
文字矩形枠2.bat
----------
@REM 文字矩形枠2
@echo off
REM #jww
REM #cd
REM #h3 範囲内「文字」データのみ選択
REM #hc 範囲選択してください
REM #g1 全レイヤグループ
REM #e
jgawk -f ch_rect2.awk jwc_temp.txt>temp.txt
copy temp.txt jwc_temp.txt
del temp.txt
goto end
# 範囲選択から、左AM0時「確定 基点(free)」
# 横文字のみ対象
:end
ch_rect2.awk
----------
###### 文字矩形枠2 #######
BEGIN{
lost=0 # 枠線上下オフセット(初期設定 0)
exl=0 # 枠線左右延長(初期設定 0)
lc="lc9" # 補助線色
lt="lt9" # 補助線種
dq="\"" # ダブルコーテーション
sp=" " # スペース
pi=atan2(0,-1) # 円周率
hf=0.5 # 係数(1/2)
k=1000000 # 誤差補正係数
kd=180/pi # rad/deg変換
} # <BEGIN>
/^hq/{ next}
## 縮尺取得
/^hs/{for(i=0;i<=9;i++)S[i]=$(i+2);
S["a"]=$12;S["b"]=$13;S["c"]=$14;
S["d"]=$15;S["e"]=$16;S["f"]=$17}
/^lg/{ lg=substr($1,3);sc=S[lg] # 係数(1/尺度)
lost=sc*lost;ost=sc*ost;cost=sc*cost # 図寸設定
rost=sc*rost;exl=sc*exl} # 図寸設定
## 文字幅/文字高さ
/^hcw/{for(i=0;i<=9;i++)cw[i+1]=$(i+2)} # 文字幅
/^hch/{for(i=0;i<=9;i++)ch[i+1]=$(i+2)} # 文字高さ
## 文字高さ取得
/^cn/{ if($1=="cn0"){cwh=$2;cht=sc*$3} # 任意サイズ
else if(substr($1,4,1)=="$"){} # スキップ
else{h=substr($1,3);cht=sc*ch[h]}} # 規定文字種
## 文字データ取得/座標
/^ch/{ nf=NF # フィールド数(半角スペース対応)
x0=$2;y0=$3 # 基点座標
hwth=$4;vwth=$5 # 文字列幅(水平/垂直)
wth=sqrt($4^2+$5^2) # 文字列幅(任意角度)
th=atan2($5,$4);ath=kd*th # 文字傾き
dx=int($4*k)/k;dy=int($5*k)/k # 微小角補正
r=(2*lost+cht)/2 # 円弧半径
## 文字データ
chr=substr($6,2) # 作図済文字
if(nf>6){ # 半角スペース対応
for(i=7;i<=nf;i++){chr=chr sp $(i)}
}else{}
chnr=length(chr) # 文字数(半角)
## 座標計算
# 水平
if(dy==0 && dx>0){
x1=x0-exl;y1=y0-lost;x2=x0+hwth+exl;y2=y1
x5=x1;y5=y0+cht+lost;x6=x2;y6=y5}
# 垂直(90°)
else if(dx==0){
if(dy>0){
x1=x0+lost;y1=y0-exl;x2=x1;y2=y0+dy+exl
x5=x0-cht-lost;y5=y1;x6=x5;y6=y2}
# 垂直(-90°)
if(dy<0){
x1=x0-lost;y1=y0+exl;x2=x1;y2=y0+dy-exl
x5=x0+cht+lost;y5=y1;x6=x5;y6=y2}}
else{
x1=x0+lost*sin(th)-exl*cos(th)
y1=y0-lost*cos(th)-exl*sin(th)
x2=x0+wth*cos(th)+lost*sin(th)+exl*cos(th)
y2=y0+wth*sin(th)-lost*cos(th)+exl*sin(th)
x5=x1-(cht+2*lost)*sin(th);y5=y1+(cht+2*lost)*cos(th)
x6=x5+(wth+2*exl)*cos(th);y6=y5+(wth+2*exl)*sin(th)}
# 線色/線種
print lc # 線色
print lt # 線種
## 矩形枠作図
print x1,y1,x2,y2
print x1,y1,x5,y5
print x2,y2,x6,y6
print x5,y5,x6,y6
next } # <ch>
{print $0}
| 固定リンク

コメント