jw_cad 外部変形 - (1308) luaで曲線データを確認する(pl) -

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

 

luaで曲線データを確認する(pl)

:luaで曲線データを確認する(pl)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | lua - myfiles > jwc_temp.txt
)
goto:eof

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

#!この次の行からプログラムを書いてください
i = 0
pln = 0
pl = {}
plno = {}
plflg = 0
plno[0] = 0
for line in io.lines(arg[1]) do
  F = {}
  line:gsub("%S+", function (x) table.insert(F, x) end)
  if line:match("^hq") then
    print("bz")
  end
  if line:match("^pl") then
    plflg = 1
  end
  if line:match("^#") and plflg == 1 then
    pln = pln + 1
    plno[pln] = i
    plflg = 0
  end
  if line:match("^hhp([1-9][0-9]?)ch") then
    i = line:match("^hhp([1-9][0-9]?)ch")*1
  end
  if line:match("^[ ]") and plflg == 1 then
    i = i + 1
    pl[i] = F
  end
end

for i = 1, pln do
  print( ("lc%d"):format(i+6))
  print("pl")
  for j = plno[i-1]+1, plno[i] do
    x1, y1, x2, y2 = unpack(pl[j])
    print( ("%s %s %s %s"):format(x1, y1, x2, y2))
  end
  print("#")
end

 

 

指示した曲線データを色を指定して表示画面に書き換えています。