jw_cad 外部変形 - (1313) luaで円環ソリッドを確認する(sg:楕円同一幅) -

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

 

luaで円環ソリッドを確認する(sg:楕円同一幅)

:luaで円環ソリッドを確認する(sg:楕円同一幅)
@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

#!この次の行からプログラムを書いてください
function flatten(a)
  local i, j, k
  local c = {}
  for i in pairs(a) do
    if type(a[i]) == "table" then
      --while #a[i] == 1 do a[i] = a[i][1] end
      for j in pairs(a[i]) do
        if type(a[i][j]) == "table" then
          --while #a[i][j] == 1 do a[i][j] = a[i][j][1] end
          for k in pairs(a[i][j]) do
            table.insert(c, a[i][j][k])
          end
        else
          table.insert(c, a[i][j])
        end
      end
    else
      table.insert(c, a[i])
    end
  end
  return c
end

function join(a, FS)
  if type(a) ~= "table" then return a end
  if FS == nil then FS = " " end
  return table.concat(flatten(a), FS)
end

sln = 0
sl = {}
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("^sg") then
    sln = sln + 1
    sl[sln] = F
  end
end

for i = 1, sln do
  print( ("lc%d"):format(i+6))
  print(join(sl[i]))
end

 

 

選択した円環ソリッド図形を色を指定して、表示画面に描いています。