Files
DataWall/LuaLibs/PanelSaw.lua
T

115 lines
2.7 KiB
Lua

-- PanelSaw.lua by Egalware s.r.l. 2025/09/02
-- Creazione lista taglio e/o programmi di taglio per sezionatrici
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
local PanelSaw = {}
local function GetPanelList()
local PanelList = {}
local idMachGroup = EgtGetFirstMachGroup()
local nMachGroupCount = EgtGetMachGroupCount()
-- nessun MachGroup ossia nessun pannello: si esce subito
if ( not idMachGroup) or ( nMachGroupCount == 0) then
return nil
end
-- per ogni MachGroup si estraggono le informazioni del pannello
for i = 1, nMachGroupCount do
local vPartInfo = EgtSplitString( EgtGetInfo( idMachGroup, 'PART1', 's'))
local idPart = vPartInfo[1]
table.insert( PanelList, {})
PanelList[i].dLength = EgtGetInfo( idMachGroup, 'PANELLEN', 'd')
PanelList[i].dWidth = EgtGetInfo( idMachGroup, 'PANELWIDTH', 'd')
PanelList[i].dThickness = EgtGetInfo( idMachGroup, 'PANELHEIGHT', 'd')
PanelList[i].sMaterial = EgtGetInfo( idMachGroup, 'MATERIAL', 's')
PanelList[i].idProd = EgtGetInfo( idMachGroup, 'PRODID', 'i')
PanelList[i].idPatt = EgtGetInfo( idMachGroup, 'PATTID', 'i')
PanelList[i].nPdn = EgtGetInfo( idPart, 'PDN', 'i')
PanelList[i].sName = EgtGetInfo( idPart, 'NAM', 's')
-- in questa modalità ogni MachGroup è 1 pezzo, non esistono multipli
-- TODO valutare se raggruppare i pannelli uguali per la cutting list
PanelList[i].nQuantity = 1
idMachGroup = EgtGetNextMachGroup( idMachGroup)
end
return PanelList
end
local function GetSheetList()
local SheetList = {
{
dLength = 2800,
dWidth = 2070,
dThickness = 8
},
{
dLength = 2800,
dWidth = 2070,
dThickness = 18
}
}
return SheetList
end
local function GetProjectInfo()
local ProjectInfo = {}
local idBtlInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL
ProjectInfo.sProjectName = EgtGetInfo( idBtlInfo, 'PROJECTNAME', 's') or ''
return ProjectInfo
end
local function BuildCuttingList( sOutputType)
local LinesToWrite = {}
local PanelList = GetPanelList()
local SheetList = GetSheetList()
local ProjectInfo = GetProjectInfo()
-- Casadei
if sOutputType == 'Cutty' then
-- Homag Optimat
elseif sOutputType == 'Homag' then
-- formato json generico
else
end
return LinesToWrite
end
function PanelSaw.GenerateCuttingList( sOutputType)
local LinesToWrite = BuildCuttingList( sOutputType)
-- scrittura file
local file = io.open( sProjectName .. '.' .. sOutputType, "w")
file:write( table.concat( LinesToWrite, "\n"))
file:close()
return
end
return PanelSaw