jw_cad 外部変形 - (1271) luaで点マーカを描く -

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

 

luaで点マーカを描く

:luaで点マーカを描く
@echo off
set c=%*
if defined c call:set %c%
if exist %~dpn0.txt (
  for /f "tokens=*" %%a in (%~dpn0.txt) do call:set %%a
)
if not defined code set code=0
if not defined size set size=1
if defined c (
  echo %code% %size%> %~dpn0.txt
)

for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | lua > jwc_temp.txt
)
goto:eof

REM #jww
REM #1%d 点位置を指示して下さい
REM #99#
REM #c マーカコード番号, 倍率
REM #e

:set
if not defined code set code=%1
if not defined size set size=%2
if "%1" == "/" set code=
if "%2" == "/" set size=
goto:eof

#!この次の行からプログラムを書いてください
hp = {}
code = os.getenv('code')
size = os.getenv('size')
for line in io.lines("myfiles") do
  F = {}
  string.gsub(line, "%S+", function (x) table.insert(F, x) end)
  if string.match(line, "^hk") then hk = F[2] end
  if string.match(line, "^hp[1-9]") then
    hp[string.gsub(string.gsub(F[1], "hp", ""), "-", "")*1] = {F[2], F[3]}
  end
end
n = #hp
for i = 1, n do
  print( ("pt %s %s %s %s %s"):format(hp[i][1], hp[i][2], size, hk, code))
end