jw_cad 外部変形 - (706) パワーシェルで点データを確認する(pt) -

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

 

パワーシェルで点データを確認する(pt)

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

REM #jww
REM #h1
REM #e

#!ここから more +n %0 の n 行目:最初の行は 0 行
(gc jwc_temp.txt) | foreach {
  switch -regex -case ($_)
  {
    '^hq' {
      "hd"
      continue
    }
    '^hk\s+(\S+)' {
      $hk = ([double] $matches[1])
      continue
    }
    '^pt\s+(\S+ \S+)' {
      $F = ([regex]::split($matches[1],' +')[0..1] | %{ [double] $_ })
      $x = $F[0]
      $y = $F[1]
      $lx = [Math]::cos($hk * [Math]::PI / 180)
      $ly = [Math]::sin($hk * [Math]::PI / 180)
      "cc4"
      "cn0 5 5 0.5 2"
#      "ch " + $x + " " + $y + " " + $lx + " " + $ly + ' "ようこそ ありがとう'
      $ch = [string]::join(" ",("ch",$x,$y,$lx,$ly,'"ようこそ ありがとう'))
      "$ch"
      "$_"
      continue
    } else {
      "$_"
      continue
    }
  }
} | sc jwc_temp.txt

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