From 46cdaa494b02c5eda8d07ab476b8e2e738c3bfaf Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Mon, 3 Mar 2025 15:03:18 +0100 Subject: [PATCH] - Per CalculateStrategies e CalculateMachinings si ribalta pezzo per averlo in posizione corretta nel momento dell'esecuzione della Proc - Modificata RotatePart. Adesso bisogna passare il numero di rotazioni da fare --- LuaLibs/BeamExec.lua | 44 +++++++++++++++++++++++++++----------------- LuaLibs/BeamLib.lua | 10 +++++----- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index ff71024..cbad602 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -979,10 +979,24 @@ end -- esegue le strategie migliori che ha precedentemente scelto local function CalculateMachinings( vProc, Part) local bAreAllApplyOk = true + local CurrRotation = 1 + local NextRotation = 1 -- applico le strategie scelte for i = 1, #vProc do -- processo tutte le feature attive applicando le lavorazioni local Proc = vProc[i] + -- si sistemano i pezzi per le rotazioni + if Proc.bDown and CurrRotation ~= 3 then + BeamLib.RotatePart( Part, 3 - CurrRotation) + CurrRotation = 3 + elseif Proc.bSide and CurrRotation ~= 2 then + BeamLib.RotatePart( Part, 2 - CurrRotation) + CurrRotation = 2 + elseif CurrRotation ~= 1 then + BeamLib.RotatePart( Part, NextRotation - CurrRotation) + CurrRotation = 1 + end + -- si applicano le strategie if Proc.nFlg ~= 0 and Proc.ChosenStrategy then -- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia) local StrategyScriptName = Proc.ChosenStrategy.sStrategyId .. '\\' .. Proc.ChosenStrategy.sStrategyId @@ -1032,20 +1046,8 @@ function BeamExec.GetProcessings( PARTS) -- inserisco una tabella vuota table.insert( vProcRot, {}) end - - -- ruoto il grezzo per calcolare la fattibilità delle lavorazioni nella prossima rotazione - -- vettore movimento grezzi per rotazione di 90deg ogni step - local dDeltaYZ = PARTS[nPart].b3Raw:getDimY() - PARTS[nPart].b3Raw:getDimZ() - local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) - local bPreMove = ( dDeltaYZ < 0) - -- ruoto le travi della fase corrente - if bPreMove then - EgtMoveRawPart( PARTS[nPart].idRaw, vtMove) - end - EgtRotateRawPart( PARTS[nPart].idRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) - if not bPreMove then - EgtMoveRawPart( PARTS[nPart].idRaw, vtMove) - end + -- rotazione pezzo di 90° per volta + BeamLib.RotatePart( PARTS[nPart], 1) -- aggiorno info pezzo PARTS[nPart].b3Raw = EgtGetRawPartBBox( PARTS[nPart].idRaw) PARTS[nPart].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[nPart].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) @@ -1314,6 +1316,11 @@ function BeamExec.ProcessMachinings( PARTS) PROCESSINGS[nPart].Rotation[dRotIndex] = CalculateStrategies( PROCESSINGS[nPart].Rotation[dRotIndex], PARTS[nPart]) -- tra le calcolate, sceglie la migliore PROCESSINGS[nPart].Rotation[dRotIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[dRotIndex]) + -- rotazione pezzo di 90° per volta + BeamLib.RotatePart( PARTS[nPart], 1) + -- aggiorno info pezzo + PARTS[nPart].b3Raw = EgtGetRawPartBBox( PARTS[nPart].idRaw) + PARTS[nPart].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[nPart].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) end -- scrittura nel log del risultato della scelta della strategia migliore tra quelle disponibili @@ -1360,10 +1367,12 @@ function BeamExec.ProcessMachinings( PARTS) EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( PARTS[nPart].idRaw) .. ' Part=' .. tostring( PARTS[nPart].id) .. ' ***', 1) -- creazione effettiva delle lavorazioni + local nCurrPosition = 1 -- se c'è almeno una lavorazione in posizionamento con trave ribaltata if bSomeFeatureDown then local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2) - BeamLib.RotatePart( PARTS[nPart], nRotation) + BeamLib.RotatePart( PARTS[nPart], nRotation - nCurrPosition) + nCurrPosition = nRotation EgtSetInfo( nDispId, 'ROT', -2) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'DOWN') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1385,7 +1394,8 @@ function BeamExec.ProcessMachinings( PARTS) end end local nRotation = EgtIf( nInitialPosition + 1 > 4, nInitialPosition + 1 - 4, nInitialPosition + 1) - BeamLib.RotatePart( PARTS[nPart], nRotation) + BeamLib.RotatePart( PARTS[nPart], nRotation - nCurrPosition) + nCurrPosition = nRotation EgtSetInfo( nDispId, 'ROT', -1) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'SIDE') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1405,7 +1415,7 @@ function BeamExec.ProcessMachinings( PARTS) end end - BeamLib.RotatePart( PARTS[nPart], nInitialPosition) + BeamLib.RotatePart( PARTS[nPart], nInitialPosition - nCurrPosition) -- aggiunta lavorazioni in ultima fase MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 27a275b..15b74cf 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -143,12 +143,12 @@ end ------------------------------------------------------------------------------------------------------------- --- funzione che ruota il pezzo, da lanciare per creare la disposizione corretta -function BeamLib.RotatePart( Part, nPosition) +function BeamLib.RotatePart( Part, nNumberOfRotations) -- primo posizionamento - if nPosition == 1 then + if nNumberOfRotations == 0 then ; -- il pezzo è già in posizione -- rotazione 90° - elseif nPosition == 2 then + elseif abs( nNumberOfRotations) == 1 then local dDeltaYZ = EgtGetRawPartBBox( Part.idRaw):getDimY() - EgtGetRawPartBBox( Part.idRaw):getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = dDeltaYZ < 0 @@ -161,7 +161,7 @@ function BeamLib.RotatePart( Part, nPosition) nRId = EgtGetNextRawPart( nRId) end -- rotazione 180° - elseif nPosition == 3 then + elseif abs( nNumberOfRotations) == 2 then -- ribalto le travi della fase corrente local nRId = Part.idRaw while nRId do @@ -169,7 +169,7 @@ function BeamLib.RotatePart( Part, nPosition) nRId = EgtGetNextRawPart( nRId) end -- rotazione 270° - elseif nPosition == 4 then + elseif abs( nNumberOfRotations) == 3 then local dDeltaYZ = EgtGetRawPartBBox( Part.idRaw):getDimY() - EgtGetRawPartBBox( Part.idRaw):getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = dDeltaYZ < 0