jw_cad 外部変形 - (1425) vbscriptで指示円を確認する(ci) -

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

 

vbscriptで指示円を確認する(ci)

:vbscriptで指示円を確認する(ci)
@echo off
if not exist %~dp0eval.vbs echo ExecuteGlobal WScript.StdIn.ReadAll > %~dp0eval.vbs
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  (
:   echo Option Explicit
    echo On Error Resume Next
:   echo On Error GoTo 0
    more +%%n %0
  ) | cscript //nologo %~dp0eval.vbs > jwc_temp.txt
)
goto:eof

REM #jww
REM #1%dci 円を指示してください
REM #99#
REM #bz
REM #e

#!この次の行からプログラムを書いてください
'1)正規表現
Dim re
Set re = New RegExp
re.IgnoreCase = True '大文字と小文字を区別しない
re.Global = True '文字列全体を検索する

function reSplit(str)
  re.Pattern = "[ ]+"
  reSplit = Split(Trim(re.Replace(str," ")))
end function

function reTest(pat, str)
  re.Pattern = pat
  reTest = re.Test(str)
end function

'4)ユーザ定義関数
function hypot(x, y)
  hypot = sqr(x * x + y * y)
end function

function lnlength(x) '線長
  if typename(x) = "String" then x = Split(Trim(x))
  lnlength = hypot(x(2) - x(0), x(3) - x(1))
end function

Dim line, F
Dim hp(100), hpn
Dim ci(100), cin, j
With CreateObject("Scripting.FileSystemObject")
  With .OpenTextFile("myfiles")
  Do While Not .AtEndOfStream
    line = .ReadLine: F = reSplit(line)
    if reTest("^hp([1-9][0-9]?)ci",line) then '指示点の座標値
      hpn = CInt(re.Replace(F(0),"$1"))
      hp(hpn) = Array(F(1), F(2))
    end if
    if reTest("^hhp([1-9][0-9]?)ci",line) then '指示円番号
      cin = CInt(re.Replace(line,"$1"))
    end if
    if reTest("^ci",line) then '指示円
      ci(cin) = F
      for j = 1 to UBound(F): ci(cin)(j) = Cdbl(ci(cin)(j)): next
    end if
  Loop
  End With
End With

WScript.Echo "bz"
Dim i, x, y
for i = 1 to cin
  x = ci(i)(1)
  y = ci(i)(2)
  WScript.Echo Join(Array("pt", x, y))
  WScript.Echo Join(Array("ci", Join(hp(i)), 1))
next