jw_cad 外部変形 - (707) パワーシェルで指示文字を確認する(ch) -

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

 

パワーシェルで指示文字を確認する(ch)

:パワーシェルで指示文字を確認する(ch)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  more +%%n %0 | powershell -command -
)
goto:eof

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

#!ここから more +n %0 の n 行目:最初の行は 0 行
$hp = 0,1,2,3,4,5
$ch = 0,1,2,3,4,5
(gc jwc_temp.txt) | foreach {
  switch -regex -case ($_)
  {
    '^hp(\d+)ch-?\s+(\S+ \S+)' {
      $hp[$matches[1]] = $matches[2]
      continue
    }
    '^hhp(\d+)ch' {
      $i = $matches[1]
      continue
    }
    '^hq' {
      "hd"
      continue
    }
    '^(c[hvsroptkz2]\s+\S+ \S+ \S+ \S+) "(.+)' {
      $ch[$i] = [regex]::split($matches[1],' +')
      $ch[$i] += $matches[2]
      $x1 = [double] $ch[$i][1]
      $y1 = [double] $ch[$i][2]
      $lx = [double] $ch[$i][3]
      $ly = [double] $ch[$i][4]
      $a = [Math]::atan2($ly, $lx)
      $l = [Math]::sqrt($lx * $lx + $ly * $ly)
      $x2 = $x1 + $l * [Math]::cos($a)
      $y2 = $y1 + $l * [Math]::sin($a)
      "$x1 $y1 $x2 $y2"
      continue
    }
  }
} | sc jwc_temp.txt

#ここまで powershell は 文末に必ず空白行を置いてください