Merge branch 'PanelSawCuttingListExport' into develop
This commit is contained in:
@@ -0,0 +1,343 @@
|
||||
-- PanelSaw.lua by Egalware s.r.l. 2025/09/02
|
||||
-- Creazione lista taglio e/o programmi di taglio per sezionatrici
|
||||
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
|
||||
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].sMaterialFullName = EgtGetInfo( idMachGroup, 'MATERIAL', 's') or '0000-MATERIAL'
|
||||
local vMaterialInfo = EgtSplitString( PanelList[i].sMaterialFullName, '-')
|
||||
PanelList[i].idMaterial = vMaterialInfo[1]
|
||||
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
|
||||
-- TODO aggiungere labeling, edgebanding, graindirection, ...
|
||||
|
||||
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_Cutty( PanelList, SheetList, ProjectInfo)
|
||||
|
||||
local Lines = {}
|
||||
|
||||
local F0 = {
|
||||
Header = { 'F0'},
|
||||
HeaderPlaceholders = { '%s'},
|
||||
Values = { ' 7.70', '210700', '150300'},
|
||||
ValuesPlaceholders = { '%s', '%s', '%s'}
|
||||
}
|
||||
|
||||
local F0b = {
|
||||
Header = { 'F0b', '""', '""', '""', '""'},
|
||||
HeaderPlaceholders = { '%s', '%s', '%s', '%s', '%s'}
|
||||
}
|
||||
|
||||
local F1 = {
|
||||
Header = { 'F1', PanelList[1].dThickness, 0, 0, 0},
|
||||
HeaderPlaceholders = { '%s', '%.3f', '%.3f', '%.3f', '%.3f'},
|
||||
ValuesList = {},
|
||||
ValuesPlaceholders = { '%.3f', '%.3f', '%d', '%d', '%d', '%d', '%d', '%.3f', '%d', '%d', '%d', '%d'}
|
||||
}
|
||||
for i = 1, #SheetList do
|
||||
F1.ValuesList[i] = { SheetList[i].dLength, SheetList[i].dWidth, 99, 200, 1, 1, 0, 1, 0, 0, 0, 0}
|
||||
end
|
||||
|
||||
local F2 = {
|
||||
Header = { 'F2', 0, 0, 0},
|
||||
HeaderPlaceholders = { '%s', '%d', '%d', '%d'},
|
||||
ValuesList = {},
|
||||
ValuesPlaceholders = { '%.3f', '%.3f', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%.3f', '%d', '%d', '%d', '%.3f', '%.3f'}
|
||||
}
|
||||
for i = 1, #PanelList do
|
||||
F2.ValuesList[i] = { PanelList[i].dLength, PanelList[i].dWidth, PanelList[i].nQuantity, 0, 0, 0, 0, PanelList[i].nPdn, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1500, 0, 0, 0, 0, 0}
|
||||
end
|
||||
|
||||
local F7 = {
|
||||
Header = { 'F7', 3052, 0},
|
||||
HeaderPlaceholders = { '%s', '%s', '%d'},
|
||||
ValuesList = {
|
||||
{ 218, 436},
|
||||
{ 167, 669},
|
||||
{ 204, 408},
|
||||
{ 204, 204},
|
||||
{ 204, 204},
|
||||
{ 209, 209},
|
||||
{ 167, 167},
|
||||
{ 213, 213},
|
||||
{ 229, 229},
|
||||
{ 164, 164},
|
||||
{ 150, 150}
|
||||
},
|
||||
ValuesPlaceholders = {
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'},
|
||||
{ '%s', '%s'}
|
||||
}
|
||||
}
|
||||
|
||||
local F7b = {
|
||||
Header = { 'F7b', 0, 0, 0, 0},
|
||||
HeaderPlaceholders = { '%s', '%.3f', '%.3f', '%.3f', '%.3f'},
|
||||
Values = {},
|
||||
ValuesPlaceholders = {}
|
||||
}
|
||||
|
||||
local F8 = {
|
||||
Header = { 'F8', 0, 0, 20, 20, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
HeaderPlaceholders = { '%s', '%.3f', '%.3f', '%d', '%d', '%d', '%d', '%.3f', '%d', '%d', '%d', '%d', '%d', '%d', '%.3f', '%d', '%d', '%d', '%d', '%d', '%d', '%.3f', '%.3f', '%.3f'}
|
||||
}
|
||||
|
||||
local F9 = {
|
||||
Header = { 'F9', 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 4.3, 0, 0, 0, 2, 0, 2450, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
HeaderPlaceholders = { '%s', '%d', '%.3f', '%d', '%.3f', '%.3f', '%.3f', '%.3f', '%.3f', '%d', '%d', '%.3f', '%d', '%d', '%d', '%d', '%.3f', '%.3f', '%d', '%d', '%.3f', '%.3f', '%.3f', '%.3f', '%d', '%d', '%.3f', '%.3f'}
|
||||
}
|
||||
|
||||
local F3 = {
|
||||
Header = { 'F3'},
|
||||
HeaderPlaceholders = { '%s'}
|
||||
}
|
||||
|
||||
local E0 = {
|
||||
Header = { 'E0'},
|
||||
HeaderPlaceholders = { '%s'}
|
||||
}
|
||||
|
||||
-- F0
|
||||
table.insert( Lines, string.format( table.concat( F0.HeaderPlaceholders, ' '), table.unpack( F0.Header)))
|
||||
table.insert( Lines, string.format( table.concat( F0.ValuesPlaceholders, ' '), table.unpack( F0.Values)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F0b
|
||||
table.insert( Lines, string.format( table.concat( F0b.HeaderPlaceholders, ' '), table.unpack( F0b.Header)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F1 - sheets
|
||||
table.insert( Lines, string.format( table.concat( F1.HeaderPlaceholders, ' '), table.unpack( F1.Header)))
|
||||
for i = 1, #F1.ValuesList do
|
||||
local Values = F1.ValuesList[i]
|
||||
local Placeholders = F1.ValuesPlaceholders
|
||||
table.insert( Lines, string.format( table.concat( Placeholders, ' '), table.unpack( Values)))
|
||||
end
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F2 - panels
|
||||
table.insert( Lines, string.format( table.concat( F2.HeaderPlaceholders, ' '), table.unpack( F2.Header)))
|
||||
for i = 1, #F2.ValuesList do
|
||||
local Values = F2.ValuesList[i]
|
||||
local Placeholders = F2.ValuesPlaceholders
|
||||
table.insert( Lines, string.format( table.concat( Placeholders, ' '), table.unpack( Values)))
|
||||
end
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F7
|
||||
table.insert( Lines, string.format( table.concat( F7.HeaderPlaceholders, ' '), table.unpack( F7.Header)))
|
||||
for i = 1, #F7.ValuesList do
|
||||
local Values = F7.ValuesList[i]
|
||||
local Placeholders = F7.ValuesPlaceholders[i]
|
||||
table.insert( Lines, string.format( table.concat( Placeholders, ' '), table.unpack( Values)))
|
||||
end
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F7b
|
||||
table.insert( Lines, string.format( table.concat( F7b.HeaderPlaceholders, ' '), table.unpack( F7b.Header)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F8
|
||||
table.insert( Lines, string.format( table.concat( F8.HeaderPlaceholders, ' '), table.unpack( F8.Header)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F9
|
||||
table.insert( Lines, string.format( table.concat( F9.HeaderPlaceholders, ' '), table.unpack( F9.Header)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
-- F3
|
||||
table.insert ( Lines, string.format( table.concat( F3.HeaderPlaceholders, ' '), table.unpack( F3.Header)))
|
||||
|
||||
-- E0
|
||||
table.insert( Lines, string.format( table.concat( E0.HeaderPlaceholders, ' '), table.unpack( E0.Header)))
|
||||
|
||||
-- linea vuota
|
||||
table.insert( Lines, '')
|
||||
|
||||
return Lines
|
||||
end
|
||||
|
||||
|
||||
local function BuildCuttingList( PanelList, sOutputType)
|
||||
|
||||
local LinesToWrite = {}
|
||||
local SheetList = GetSheetList()
|
||||
local ProjectInfo = GetProjectInfo()
|
||||
local dRequiredThickness = PanelList[1].dThickness
|
||||
|
||||
-- solo gli sheets dello spessore corretto vanno considerati
|
||||
local ActualSheetList = {}
|
||||
for i = 1, #SheetList do
|
||||
if abs( SheetList[i].dThickness - dRequiredThickness) < 10 * GEO.EPS_SMALL then
|
||||
ActualSheetList[#ActualSheetList+1] = {
|
||||
dLength = SheetList[i].dLength,
|
||||
dWidth = SheetList[i].dWidth,
|
||||
dThickness = SheetList[i].dThickness
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Casadei
|
||||
if sOutputType == 'CUTTY' then
|
||||
|
||||
LinesToWrite = BuildCuttingList_Cutty( PanelList, ActualSheetList, ProjectInfo)
|
||||
|
||||
-- Homag Optimat
|
||||
elseif sOutputType == 'HOMAG' then
|
||||
|
||||
|
||||
end
|
||||
|
||||
return LinesToWrite
|
||||
end
|
||||
|
||||
|
||||
-- restituisce i pannelli raggruppati per coppia materiale-spessore univoca
|
||||
local function GroupByMaterial( PanelList)
|
||||
local PanelsGroupedByMaterial = {}
|
||||
|
||||
for i = 1, #PanelList do
|
||||
local idMaterial = PanelList[i].idMaterial
|
||||
local dMaterialThickness = PanelList[i].dThickness
|
||||
|
||||
-- si crea una chiave unica dalla coppia
|
||||
local key = idMaterial .. "_" .. tostring( dMaterialThickness)
|
||||
|
||||
-- se la chiave non esiste già nella tabella, si crea
|
||||
if not PanelsGroupedByMaterial[key] then
|
||||
PanelsGroupedByMaterial[key] = {}
|
||||
end
|
||||
|
||||
-- aggiunta del pezzo corrente al gruppo chiave corrispondente
|
||||
table.insert( PanelsGroupedByMaterial[key], PanelList[i])
|
||||
end
|
||||
|
||||
return PanelsGroupedByMaterial
|
||||
end
|
||||
|
||||
|
||||
function PanelSaw.GenerateCuttingList( sOutputType)
|
||||
|
||||
local PanelList = GetPanelList()
|
||||
local PanelsGroupedByMaterial = GroupByMaterial( PanelList)
|
||||
|
||||
for key, PanelListSingleMaterial in pairs( PanelsGroupedByMaterial) do
|
||||
|
||||
-- path in cui scrivere i file
|
||||
local sCurrentNgePath, sCurrentNgeName = EgtSplitPath( EgtGetCurrFilePath())
|
||||
|
||||
if sOutputType then
|
||||
-- costruzione lista istruzioni
|
||||
local LinesToWrite = BuildCuttingList( PanelListSingleMaterial, sOutputType)
|
||||
|
||||
-- scrittura file
|
||||
local sFilename = sCurrentNgePath .. 'CutList-' .. sCurrentNgeName .. '-' .. key .. '.' .. sOutputType
|
||||
local hFile, nFileErr = io.open( sFilename, 'w')
|
||||
if not hFile then
|
||||
EgtOutLog( 'Error creating cutting list : IO error ' .. tostring( nFileErr))
|
||||
return false
|
||||
end
|
||||
hFile:write( table.concat( LinesToWrite, "\n"))
|
||||
hFile:close()
|
||||
|
||||
-- se nessun tipo si deve scrivere un json semplice
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
return PanelSaw
|
||||
+32
-8
@@ -18,13 +18,14 @@ NEST.MACH_AREA_USE_OTHER_DIAM = 1 -- 0
|
||||
NEST.MACH_AREA_OTHER_DIAM = 200
|
||||
NEST.MACH_AREA_IGNORE_3rdFACE = 1 -- 0
|
||||
|
||||
if NEST.FLAG ~= 11 then
|
||||
local sLog = 'NestProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. LEN[1] .. ', ' .. WIDTH[1]
|
||||
EgtOutLog( sLog)
|
||||
|
||||
local sLog = 'NestProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. LEN[1] .. ', ' .. WIDTH[1]
|
||||
EgtOutLog( sLog)
|
||||
|
||||
-- Cancello file di log specifico
|
||||
local sLogFile = EgtChangePathExtension( NEST.FILE, '.txt')
|
||||
EgtEraseFile( sLogFile)
|
||||
-- Cancello file di log specifico
|
||||
local sLogFile = EgtChangePathExtension( NEST.FILE, '.txt')
|
||||
EgtEraseFile( sLogFile)
|
||||
end
|
||||
|
||||
-- Imposto direttorio libreria specializzata per Travi
|
||||
EgtAddToPackagePath( NEST.BASEDIR .. '\\LuaLibs\\?.lua')
|
||||
@@ -56,6 +57,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')
|
||||
@@ -1686,7 +1689,7 @@ EgtResetCurrMachGroup()
|
||||
|
||||
-- modalità nesting utile per cabinet: un grezzo per ogni pezzo, pezzo centrato nel grezzo. Il grezzo non viene preso da magazzino ma creato ad hoc, con un dato sovramateriale.
|
||||
-- il numero del MachGroup deve coincidere con il PDN del pezzo originale
|
||||
if WD.ENABLE_SIMPLE_NESTING then
|
||||
if NEST.FLAG ~= 11 and WD.ENABLE_SIMPLE_NESTING then
|
||||
|
||||
-- sovramateriale richiesto
|
||||
local dOverMaterial = max( 0, NEST.KERF or 2)
|
||||
@@ -1717,7 +1720,8 @@ if WD.ENABLE_SIMPLE_NESTING then
|
||||
-- si riordina in base al PDN
|
||||
table.sort( PartList, function(a, b) return tonumber( a.nPdn) < tonumber( b.nPdn) end)
|
||||
|
||||
-- per ogni singolo pezzo si creano duplo e machgroup e si settano le note opportune per poi creare i grezzi richiamando la BatchProcessNew (flag 6)
|
||||
-- per ogni singolo pezzo si chiama la fliprot per avere la migliore orientazione
|
||||
-- si creano duplo e machgroup e si settano le note opportune per poi creare i grezzi richiamando la BatchProcessNew (flag 6)
|
||||
for i = 1, #PartList do
|
||||
|
||||
local nPartId = PartList[i].nId
|
||||
@@ -1725,6 +1729,14 @@ if WD.ENABLE_SIMPLE_NESTING then
|
||||
local nPdn = PartList[i].nPdn
|
||||
local bAddCounterToNaming = PartList[i].bAddCounterToNaming
|
||||
|
||||
-- si ruotano e invertono i pezzi per avere la migliore posizione di lavorazione
|
||||
_G.NFAR = {}
|
||||
NFAR.ERR = 0
|
||||
NFAR.MSG = ''
|
||||
NFAR.PARTID = nPartId
|
||||
NFAR.BASEDIR = NEST.BASEDIR
|
||||
dofile( NEST.BASEDIR .. "\\NestFlipAndRotate.lua")
|
||||
|
||||
-- informazioni dalla parte originale
|
||||
-- box e relative dimensioni
|
||||
local nBoxLayerId = EgtGetFirstNameInGroup( nPartId, "Box")
|
||||
@@ -1778,6 +1790,18 @@ if WD.ENABLE_SIMPLE_NESTING then
|
||||
EgtResetCurrMachGroup()
|
||||
EgtOutLog( ' +++ NestProcess completed')
|
||||
|
||||
EgtOutLog( ' +++ Generating Cutting List')
|
||||
|
||||
return
|
||||
|
||||
elseif NEST.FLAG == 11 then
|
||||
|
||||
local vCuttingListType = EgtSplitString( WD.PANELSAW_TYPE)
|
||||
for i = 1, #vCuttingListType do
|
||||
local sCuttingListType = vCuttingListType[i]
|
||||
PanelSaw.GenerateCuttingList( sCuttingListType)
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user