jw_cad 外部変形 - (1306) luaで点データを確認する(pt) -

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

 

luaで点データを確認する(pt)

:luaで点データを確認する(pt)
@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

#!この次の行からプログラムを書いてください
pt = {}; i = 1
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("^hk") then
    hk = F[2]*1
  end
  if line:match("^pt") then
    if #F == 3 then
      pt[i] = {F[2]*1, F[3]*1}
      i = i + 1
    elseif #F == 6 then
      pt[i] = {F[2]*1, F[3]*1, F[4]*1, F[5]*1, F[6]*1}
      i = i + 1
    end
  end
end

ptn = #pt
d = math.rad(hk)
lx, ly = math.cos(d), math.sin(d)
str = "ようこそ ありがとう"
print("cc4")
print("cn0 5 5 0.5 2")
for i = 1, ptn do
  x, y = unpack(pt[i])
  print( ("ch %s %s %s %s \"%s"):format(x, y, lx, ly, str))
end