RE: LDCad 1.7 Alpha 1 (win+linux)
2021-08-12, 11:52 (This post was last modified: 2021-08-12, 13:34 by Milan Vančura.)
2021-08-12, 11:52 (This post was last modified: 2021-08-12, 13:34 by Milan Vančura.)
One question about scripting:
I got an idea lua scripts might help me with copying groups with their pivot point kept. And while looking around for LDCAD scripting examples, I found methods not mentioned on your Scripting API web page. Probably because lua in LDCAD evolved since the documentation was written. But what surprised me was that I could not get the list of methods by simple dump function. Are ldc objects somehow special? Or is the dump function too basic?
(I'm sorry I'm lua greenhorn, I just try to learn as I use it.)
I got an idea lua scripts might help me with copying groups with their pivot point kept. And while looking around for LDCAD scripting examples, I found methods not mentioned on your Scripting API web page. Probably because lua in LDCAD evolved since the documentation was written. But what surprised me was that I could not get the list of methods by simple dump function. Are ldc objects somehow special? Or is the dump function too basic?
(I'm sorry I'm lua greenhorn, I just try to learn as I use it.)
Code:
local seen={}
function dump(t,i)
seen[t]=true
local s={}
local n=0
for k in pairs(t) do
n=n+1 s[n]=k
end
table.sort(s)
for k,v in pairs(s) do
print(i,v)
v=t[v]
if type(v)=="table" and not seen[v] then
dump(v,i.."\t")
end
end
end
function dumpLdc()
dump(ldc,"")
end
--Register macros==============
function register()
local macro=ldc.macro('Dump ldc')
macro:setHint('Dump ldc')
macro:setEvent('run','dumpLdc')
end
register()