From 81ab09a1222d9bd908cc138a07eb362b2ca1a1e9 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Tue, 29 Apr 2025 12:53:19 +0200 Subject: [PATCH 1/2] In BatchProcessNew, si ricavano tutte le informazioni dei pezzi nestati nella barra --- BatchProcessNew.lua | 49 +++++++++++++++++++++++++++++++++++++++++--- LuaLibs/BeamExec.lua | 2 +- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index a9d33f7..06de795 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -261,8 +261,8 @@ if bToProcess then local b3Raw = EgtGetRawPartBBox( nRawId) -- Calcolo posizione estremo TR o BR della tavola rispetto a sua origine in BL local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY() + b3Raw:getDimY() * EgtIf( BeamData.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY())) - BeamData.OriXR = Point3d( b3Tab:getDimX(), dPosY, 0) - BeamData.PosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) + BeamData.ptOriXR = Point3d( b3Tab:getDimX(), dPosY, 0) + BeamData.dPosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) -- Calcolo minimo grezzo scaricabile BeamExec.CalcMinUnloadableRaw( b3Raw:getDimY(), b3Raw:getDimZ()) -- altrimenti devo recuperare i pezzi per creare la barra @@ -489,7 +489,50 @@ if bToProcess then if not vVal or #vVal < 2 then break end local nPartId = tonumber( vVal[1]) local dPosX = tonumber( vVal[2]) - table.insert( PARTS, { id = nPartId, dPosX = dPosX, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) + table.insert( PARTS, { nInd = #PARTS + 1, id = nPartId, dPosX = dPosX, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) + end + -- se lunghezza barra non settata, la leggo ora + if not dBarLen then + dBarLen = EgtGetInfo( nMGrpId, 'BARLEN', 'd') + end + -- Recupero tutte le informazioni dei pezzi + local dLen = dBarLen + for i = 1, #PARTS do + -- aggiorno grezzo precedente + PARTS[i].idRaw = EgtGetRawPartFromPart( PARTS[i].id) + PARTS[i].bIsLastPart = ( i == #PARTS) + -- dimensioni del grezzo ( comprende sovramateriale di testa e lavorazione di coda per separazione) + PARTS[i].b3Raw = EgtGetRawPartBBox( PARTS[i].idRaw) + PARTS[i].dRawLength = PARTS[i].b3Raw:getDimX() + PARTS[i].dRawWidth = PARTS[i].b3Raw:getDimY() + PARTS[i].dRawHeight = PARTS[i].b3Raw:getDimZ() + -- dimensione pezzo finito + PARTS[i].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + PARTS[i].dLength = PARTS[i].b3Part:getDimX() + PARTS[i].dWidth = PARTS[i].b3Part:getDimY() + PARTS[i].dHeight = PARTS[i].b3Part:getDimZ() + PARTS[i].bSquareSection = abs( PARTS[i].dWidth - PARTS[i].dHeight) < 100 * GEO.EPS_SMALL + PARTS[i].nIndexInParts = i + PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i]) + PARTS[i].SplittingPoints = BeamLib.GetPartSplittingPoints( PARTS[i]) + + -- sovramateriale in testa al pezzo + local dDeltaS = max( PARTS[i].dPosX - ( dBarLen - dLen), 0) + -- lunghezza grezzo (comprende sovramateriale di testa e mm tagliati in coda dalla lavorazione, tipicamente 5.4mm dello spessore lama) + local dCrawLen = PARTS[i].dRawLength + -- materiale tolto in coda dalla lavorazione di separazione + local dDeltaE = dCrawLen - PARTS[i].dLength - dDeltaS + local dDeltaNextPiece + if PARTS[i+1] then + dDeltaNextPiece = PARTS[i+1].dPosX - ( dBarLen - dLen) - dCrawLen + dDeltaE + else + dDeltaNextPiece = 10000 + end + PARTS[i].dDistanceToNextPiece = dDeltaNextPiece + + -- aggiorno la lunghezza residua della barra + dLen = dLen - dCrawLen + PARTS[i].dRestLength = dLen end end diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index e302e21..ec287c7 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -309,7 +309,7 @@ local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection) end ------------------------------------------------------------------------------------------------------------- -local function GetAvailableCombinations( PartInfo) +function BeamExec.GetAvailableCombinations( PartInfo) local CombinationList = {} CombinationList.Rotations = {0, 0, 0, 0} -- indice rotazione attiva, per calcolo collect feature From c234978cab79d503b721451a680491cb54383037 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Tue, 29 Apr 2025 15:03:29 +0200 Subject: [PATCH 2/2] - Corretta chiamata della funzione GetAvailableCombinations - Piccole correzioni varie --- LuaLibs/BeamExec.lua | 20 ++++++++++---------- LuaLibs/BeamLib.lua | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 35a13a7..1a53cef 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -482,7 +482,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b PARTS[i].bSquareSection = abs( PARTS[i].dWidth - PARTS[i].dHeight) < 100 * GEO.EPS_SMALL PARTS[i].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) PARTS[i].nIndexInParts = i - PARTS[i].CombinationList = GetAvailableCombinations( PARTS[i]) + PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i]) PARTS[i].SplittingPoints = BeamLib.GetPartSplittingPoints( PARTS[i]) else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' @@ -1078,9 +1078,12 @@ local function AddFeatureResultToGlobalList( Proc, OptionalParameters) nCompletionIndex = nCompletionIndex, dCompositeRating = dCompositeRating, sInfo = sInfo - }, - AvailableStrategies = BeamLib.TableCopyDeep( Proc.AvailableStrategies) + } } + -- scrivo le strategie disponibili solo se ne esistono + if Proc.AvailableStrategies then + RESULT[#RESULT].AvailableStrategies = BeamLib.TableCopyDeep( Proc.AvailableStrategies) + end return RESULT end @@ -1133,16 +1136,13 @@ local function CalculateMachinings( vProc, Part, nInitialRotation) local StrategyScript = require( StrategyScriptName) -- eseguo la strategia e si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati _, _ = StrategyScript.Make( true, Proc, Part, Proc.ChosenStrategy) + -- se tutte le strategie disponibili non sono applicabili else -- se non esiste una strategia scelta (non dovrebbe mai succedere) cancello da lista generale PROCESSINGS[Proc.nIndexPartInParts].Rotation[Proc.nIndexRotation][Proc.nIndexInVProc].ChosenStrategy = nil - -- se taglio testa o coda, per il momento dico che è ok. Poi serve messaggio apposito - if ID.IsHeadCut( Proc) or ID.IsTailCut( Proc) then - -- TODO dare messaggio separazione impossibile - else - error( 'UNEXPECTED ERROR: Standard feature MUST HAVE ChosenStrategy') - bAreAllApplyOk = false - end + + -- TODO dare messaggio che la feature non 0è stata eseguita nonostante la presenza di strategie disponibili + end end -- scrivo risultato in tabella globale diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 5e1472f..0db287b 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -572,6 +572,10 @@ end --- copia una tabella lua in modo ricorsivo, ossia mantiene indipendenti anche tutte le sottotabelle --- ATTENZIONE: in caso di modifiche vanno gestiti anche i tipi custom; sarebbe meglio metterla nel LuaLibs function BeamLib.TableCopyDeep( OriginalTable) + -- controllo se oggetto passato è valido, altrimenti errore. Non deve mai succedere + if not OriginalTable then + error( "TableCopyDeep : can't copy nil object") + end local CopiedTable = {} for key, value in pairs( OriginalTable) do if type( value) == "table" then