Merge branch 'HomagPanelSawExport' into develop

This commit is contained in:
luca.mazzoleni
2025-10-08 17:17:07 +02:00
+80 -5
View File
@@ -32,6 +32,7 @@ local function GetPanelList()
PanelList[i].dWidth = EgtGetInfo( idMachGroup, 'PANELWIDTH', 'd')
PanelList[i].dThickness = EgtGetInfo( idMachGroup, 'PANELHEIGHT', 'd')
PanelList[i].sMaterialFullName = EgtGetInfo( idMachGroup, 'MATERIAL', 's') or '0000-MATERIAL'
PanelList[i].sMaterialPlusThickness = PanelList[i].sMaterialFullName .. '_' .. tostring( string.format( '%.1f', PanelList[i].dThickness))
local vMaterialInfo = EgtSplitString( PanelList[i].sMaterialFullName, '-')
PanelList[i].idMaterial = vMaterialInfo[1]
PanelList[i].idProd = EgtGetInfo( idMachGroup, 'PRODID', 'i')
@@ -39,10 +40,29 @@ local function GetPanelList()
PanelList[i].nPdn = EgtGetInfo( idPart, 'PDN', 'i')
PanelList[i].sName = EgtGetInfo( idPart, 'NAM', 's')
PanelList[i].sDescription = PanelList[i].sName
local sGrainInfo = EgtGetInfo( idPart, "GRAINDIRECTION", 's')
PanelList[i].sGrainDirection = 'None'
if sGrainInfo then
local bUseGrain = ( string.sub( sGrainInfo, 7) == '1')
local sGrainDirection = string.sub( sGrainInfo, 1, 5)
if bUseGrain then
if sGrainDirection == "1,0,0" then
PanelList[i].sGrainDirection = 'Length'
elseif sGrainDirection == "0,1,0" then
PanelList[i].sGrainDirection = 'Width'
end
end
end
-- 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
-- TODO aggiungere labeling, edgebanding, graindirection, ...
-- TODO le informazioni di edgebanding devono arrivare dal btl
PanelList[i].sEdgeMaterialLeft = ''
PanelList[i].sEdgeMaterialRight = ''
PanelList[i].sEdgeMaterialTop = ''
PanelList[i].sEdgeMaterialBottom = ''
-- TODO il barcode deve arrivare dal btl
PanelList[i].sBarcode = ''
idMachGroup = EgtGetNextMachGroup( idMachGroup)
end
@@ -75,7 +95,7 @@ local function GetProjectInfo()
local ProjectInfo = {}
local idBtlInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL
ProjectInfo.sProjectName = EgtGetInfo( idBtlInfo, 'PROJECTNAME', 's') or ''
_, ProjectInfo.sProjectName = EgtSplitPath( EgtGetInfo( idBtlInfo, 'PROJECTNAME', 's') or '')
return ProjectInfo
end
@@ -122,7 +142,14 @@ local function BuildCuttingList_Cutty( PanelList, SheetList, ProjectInfo)
ValuesPlaceholders = { '%.3f', '%.3f', '%d', '%d', '%d', '%d', '%d', '%-20s', '%d', '%d', '%d', '%d', '%-50s', '%d', '%d', '%d', '%d', '%d', '%d', '%.3f', '%d', '%d', '%-85d', '%.3f', '%.3f'},
}
for i = 1, #CurrentPanelList do
F2.ValuesList[i] = { CurrentPanelList[i].dLength, CurrentPanelList[i].dWidth, CurrentPanelList[i].nQuantity, 0, 0, 0, 0, CurrentPanelList[i].nPdn, 0, 0, 0, 0, CurrentPanelList[i].sDescription, 0, 0, 0, 0, 1, 0, 1500, 0, 0, 0, 0, 0}
local nGrain = 0
if PanelList[i].sGrainDirection == 'Length' then
nGrain = 1
elseif PanelList[i].sGrainDirection == 'Width' then
nGrain = 1
CurrentPanelList[i].dLength, CurrentPanelList[i].dWidth = CurrentPanelList[i].dWidth, CurrentPanelList[i].dLength
end
F2.ValuesList[i] = { CurrentPanelList[i].dLength, CurrentPanelList[i].dWidth, CurrentPanelList[i].nQuantity, 0, nGrain, 0, 0, CurrentPanelList[i].nPdn, 0, 0, 0, 0, CurrentPanelList[i].sDescription, 0, 0, 0, 0, 1, 0, 1500, 0, 0, 0, 0, 0}
end
local F7 = {
@@ -264,9 +291,54 @@ local function BuildCuttingList_Cutty( PanelList, SheetList, ProjectInfo)
end
local function BuildCuttingList_Homag( PanelList, ActualSheetList, ProjectInfo)
local LinesToWriteList = {}
local sExtension = 'csv'
local Lines = {}
local Header = {
Values = { 'Description', 'Quantity', 'Length', 'Width', 'Material', 'Grain', 'EdgeLeft', 'EdgeRight', 'EdgeTop', 'EdgeBottom', 'OrderNumber', 'BarCode'},
ValuesPlaceholders = { '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'}
}
local Panels = {
ValuesList = {},
ValuesPlaceholders = { '%s', '%d', '%.1f', '%.1f', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' }
}
for i = 1, #PanelList do
local sGrain = PanelList[i].sGrainDirection
-- TODO questo dipenderà dalla lingua dell'esportazione; andrà fatto un tipo di esportazione specifica per ogni lingua (es: HOMAG_NL, HOMAG_ENG, ...)
if sGrain == 'None' then
sGrain = 'Geen'
elseif sGrain == 'Length' then
sGrain = 'Lengte'
elseif sGrain == 'Width' then
sGrain = 'Breedte'
end
Panels.ValuesList[i] = { PanelList[i].sDescription, PanelList[i].nQuantity, PanelList[i].dLength, PanelList[i].dWidth, PanelList[i].sMaterialPlusThickness, sGrain, PanelList[i].sEdgeMaterialLeft, PanelList[i].sEdgeMaterialRight, PanelList[i].sEdgeMaterialTop, PanelList[i].sEdgeMaterialBottom, ProjectInfo.sProjectName, PanelList[i].sBarcode}
end
-- Intestazione
table.insert( Lines, string.format( table.concat( Header.ValuesPlaceholders, ','), table.unpack( Header.Values)))
-- Lista Pannelli
for i = 1, #Panels.ValuesList do
local Values = Panels.ValuesList[i]
local Placeholders = Panels.ValuesPlaceholders
table.insert( Lines, string.format( table.concat( Placeholders, ','), table.unpack( Values)))
end
LinesToWriteList[1] = Lines
return LinesToWriteList, sExtension
end
local function BuildCuttingList( PanelList, sOutputType)
local LinesToWriteList = {}
local sExtension = ''
local SheetList = GetSheetList()
local ProjectInfo = GetProjectInfo()
local dRequiredThickness = PanelList[1].dThickness
@@ -292,10 +364,11 @@ local function BuildCuttingList( PanelList, sOutputType)
-- Homag
elseif sOutputType == 'HOMAG' then
LinesToWriteList, sExtension = BuildCuttingList_Homag( PanelList, ActualSheetList, ProjectInfo)
end
return LinesToWriteList
return LinesToWriteList, sExtension
end
@@ -335,12 +408,14 @@ function PanelSaw.GenerateCuttingList( sOutputType)
if sOutputType then
-- costruzione lista istruzioni
local LinesToWriteList = BuildCuttingList( PanelListSingleMaterial, sOutputType)
local LinesToWriteList, sExtension = BuildCuttingList( PanelListSingleMaterial, sOutputType)
for i = 1, #LinesToWriteList do
-- scrittura file
local sFilename = sCurrentNgePath .. 'CutList-' .. sCurrentNgeName .. '-' .. key .. '-' .. i .. sOutputType
sFilename = sFilename:gsub( '%.', '_')
-- aggiunta eventuale estensione
sFilename = sFilename .. '.' .. sExtension
local hFile, nFileErr = io.open( sFilename, 'w')
if not hFile then
EgtOutLog( 'Error creating cutting list : IO error ' .. tostring( nFileErr))