jw_cad 外部変形 - (708) パワーシェルで曲線データを確認する(pl) -

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

 

パワーシェルで曲線データを確認する(pl)

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

REM #jww
REM #h1
REM #hc 曲線を選択してください
REM #e

#!ここから more +n %0 の n 行目:最初の行は 0 行
$plflg = 0
$pl = @(); foreach ($i in 0..100) { $pl += 0 }
$xx = @()
$i = 0
(gc jwc_temp.txt) | foreach {
  switch -regex -case ($_)
  {
    '^hq' {
      "hd"
      continue
    }
    '^pl' {
      $plflg = 1
      $i = $i + 1
      continue
    }
    '^\s*(\S+ \S+ \S+ \S+)' {
      if ($plflg -eq 1) {
        $xx += $matches[1]
      }
      continue
    }
    '^#' {
      $pl[$i] = $xx
      $plflg = 0
      $xx = @()
      continue
    }
  }
}
&{
  $m = $i
  for ($i = 1; $i -le $m; $i++) {
    "pl"
    "lc$(6 + $i)"
    $n = $pl[$i].length - 1
    for ($j = 0; $j -le $n; $j++) {
      "$($pl[$i][$j])"
    }
    "#"
  }
} | sc jwc_temp.txt

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