RE: LDCad 1.6a (win+linux)
2018-03-12, 17:35 (This post was last modified: 2018-03-12, 18:06 by Jarema.)
2018-03-12, 17:35 (This post was last modified: 2018-03-12, 18:06 by Jarema.)
PHP Code:
<?php
--Local functions
local function get_index (tab, val)
for index, value in ipairs(tab) do
if value == val then
return index
end
end
return nil
end
PHP Code:
<?php
--Database
axle_normal_desc = {
'Technic, Axle 2','Technic, Axle 3'
,'Technic, Axle 4','Technic, Axle 5'
,'Technic, Axle 6','Technic, Axle 7'
,'Technic, Axle 8','Technic, Axle 9'
,'Technic, Axle 10','Technic, Axle 11'
,'Technic, Axle 12','Technic, Axle 16'
,'Technic, Axle 32'
}
axle_normal_num = {'3704.dat','4519.dat','3705.dat','32073.dat','3706.dat','44294.dat'
,'3707.dat','60485.dat','3737.dat','23948.dat','3708.dat','50451.dat','50450.dat'}
function runReplaceAxleHelper()
--Some dummy proof tests.
local ses=ldc.session()
if not ses:isLinked() then
ldc.dialog.runMessage('No active model.')
return
end
--Selected session
local sel=ses:getSelection()
local cnt=sel:getRefCount()
if cnt>0 then
--use the first item as base
local curPart = sel:getRef(1)
local curIdent= get_index(axle_normal_num ,curPart:getName())
local curOri= curPart:getOri()
curOri:setPos(curPart:getPos())
--Some dummy proof tests.
if curIdent == nil then
ldc.dialog.runMessage('The wrong item was chosen')
return
end
--Let the user pick the new axle.
local part=ldc.dialog.runChoice('Select a new axle', axle_normal_desc, curIdent)
if axle_normal_num[part] == nil then
else
sel:getRef(1):delete()
sel:remove()
sel:add(ldc.subfile():addNewRef(axle_normal_num[part], 4, curOri))
end
end
end