jw_cad 外部変形 - (1367) mshtaで指示文字を確認する(ch) -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

mshtaで指示文字を確認する(ch)

:mshtaで指示文字を確認する(ch)
@echo off
if exist jwc_temp.txt (
  copy jwc_temp.txt myfiles > nul
  mshta %~f0 < myfiles > jwc_temp.txt
)
goto:eof

REM #jww
REM #1%dch 文字を指示してください
REM #99#
REM #bz
REM #e

<script>
hp =
ch =

with (new ActiveXObject("Scripting.FileSystemObject")) {
  f = GetStandardStream(0) //stdin
  g = GetStandardStream(1) //stdout
  while (! f.AtEndOfStream) {
    F = ($_ = f.ReadLine()).split(/\s+/)
    if (/^hq/i .test($_)) { //hq
      g.WriteLine("bz"); continue
    }
    if (/^hp([1-9][0-9]?)ch/i.test($_)) { //hp 指示点
      i = RegExp.$1 * 1
      hp[i] = [F[1] * 1.0, F[2] * 1.0]
      continue
    }
    if (/^hhp([1-9][0-9]?)ch/i.test($_)) { //hhp~ch 指示文字番号
      chn = RegExp.$1 * 1
      continue
    }
    if (/^c[hvsroptkz2]/i.test($_)) { //ch 指示文字
      c  = F[0]
      x1 = F[1] * 1.0
      y1 = F[2] * 1.0
      lx = F[3] * 1.0
      ly = F[4] * 1.0
      F[5] = $_.split('"')[1]
      str = F[5]
      ch[chn] = [c, x1, y1, lx, ly, str]
    }
  }
  f.close()
  chn = ch.length - 1
  if (chn > 0) {
    for (i =  1; i <= chn; i++) { //指示した文字に下線を引く
      x1 = ch[i][1]
      y1 = ch[i][2]
      lx = ch[i][3]
      ly = ch[i][4]
      d = Math.atan2(ly, lx)
      l = Math.sqrt(lx * lx + ly * ly)
      x2 = x1 + l * Math.cos(d)
      y2 = y1 + l * Math.sin(d)
      g.WriteLine([x1, y1, x2, y2].join(" "))
      x = hp[i][0]
      y = hp[i][1]
      g.WriteLine(["ci", x, y, 1].join(" "))
    }
  }
}
close()
</script>

 

 

指示した文字に下線を引き、指示点に半径1mmの円をプロットしています。スクリプト言語は jscript を使用しています。