diff --git a/LuaLibs/PanelSaw.lua b/LuaLibs/PanelSaw.lua new file mode 100644 index 0000000..8ee8129 --- /dev/null +++ b/LuaLibs/PanelSaw.lua @@ -0,0 +1,115 @@ +-- 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 \ No newline at end of file diff --git a/NestProcess.lua b/NestProcess.lua index ed6c91a..f695983 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -4,7 +4,7 @@ -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() -EgtEnableDebug( false) +EgtEnableDebug( true) -- Per test --NEST = {} @@ -56,6 +56,8 @@ _G.package.loaded.WProcessDoubleCut = nil local DoubleCut = require( 'WProcessDoubleCut') _G.package.loaded.WProcessFreeContour = nil local FreeContour = require( 'WProcessFreeContour') +_G.package.loaded.PanelSaw = nil +local PanelSaw = require( 'PanelSaw') -- Carico i dati globali local WD = require( 'WallData') @@ -1778,6 +1780,9 @@ if WD.ENABLE_SIMPLE_NESTING then EgtResetCurrMachGroup() EgtOutLog( ' +++ NestProcess completed') + EgtOutLog( ' +++ Generating Cutting List') + PanelSaw.GenerateCuttingList() + return end