From 7e6d8f4172400629ab388a3f39302852d97cdbec Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Mon, 18 Nov 2024 15:29:32 +0100 Subject: [PATCH] Corretta gestione rotazione pezzo nel DISP in caso che la soluzione scelta sia una prerotazione --- LuaLibs/BeamExec.lua | 64 ++++++---------------------------------- LuaLibs/BeamLib.lua | 43 +++++++++++++++++++++++++++ LuaLibs/MachiningLib.lua | 6 ++++ 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 02bed8b..a2a8116 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1386,7 +1386,9 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) end -- si calcola la combinazione di lavorazione migliore local vProc, nInitialPosition, bSomeFeatureDown, bSomeFeatureSide = GetBestResultFromCombinationsMatrix( PROCESSINGS[nPart], PARTS[nPart]) - + -- salvo sul PART la posizione di partenza che è stata scelta + PARTS[nPart].nInitialPosition = nInitialPosition + -- debug if EgtGetDebugLevel() >= 1 then PrintFeatures( vProc, PARTS[nPart]) @@ -1422,12 +1424,8 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) -- creazione effettiva delle lavorazioni -- se c'è almeno una lavorazione in posizionamento con trave ribaltata if bSomeFeatureDown then - -- ribalto le travi della fase corrente - local nRId = PARTS[nPart].idRaw - while nRId do - EgtRotateRawPart( nRId, X_AX(), 180) - nRId = EgtGetNextRawPart( nRId) - end + local nRotation = EgtIf( nInitialPosition <= 2, nInitialPosition + 2, nInitialPosition + 2 - 4) + BeamLib.RotatePart( PARTS[nPart], nRotation) EgtSetInfo( nDispId, 'ROT', -2) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'DOWN') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1448,18 +1446,8 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) EgtSetInfo( nDispId, 'TYPE', 'MID') end end - -- vettore movimento grezzi per rotazione di 90deg - local dDeltaYZ = EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimY() - EgtGetRawPartBBox( PARTS[nPart].idRaw):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 - local nRId = PARTS[nPart].idRaw - while nRId do - if bPreMove then EgtMoveRawPart( nRId, vtMove) end - EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) - if not bPreMove then EgtMoveRawPart( nRId, vtMove) end - nRId = EgtGetNextRawPart( nRId) - end + local nRotation = EgtIf( nInitialPosition <= 3, nInitialPosition + 1, nInitialPosition + 1 - 4) + BeamLib.RotatePart( PARTS[nPart], nRotation) EgtSetInfo( nDispId, 'ROT', -1) bAreAllMachiningApplyOk, sErr, bSplitExecutedOnRot = MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'SIDE') bSplitAlreadyExecuted = bSplitAlreadyExecuted or bSplitExecutedOnRot @@ -1479,42 +1467,8 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) end end - -- ruoto il pezzo in caso la soluzione scelta sia con prerotazione - if nInitialPosition == 1 then - ; -- il pezzo è già in posizione - elseif nInitialPosition == 2 then - local dDeltaYZ = EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimY() - EgtGetRawPartBBox( PARTS[nPart].idRaw):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 - local nRId = PARTS[nPart].idRaw - while nRId do - if bPreMove then EgtMoveRawPart( nRId, vtMove) end - EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) - if not bPreMove then EgtMoveRawPart( nRId, vtMove) end - nRId = EgtGetNextRawPart( nRId) - end - elseif nInitialPosition == 3 then - -- ribalto le travi della fase corrente - local nRId = PARTS[nPart].idRaw - while nRId do - EgtRotateRawPart( nRId, X_AX(), 180) - nRId = EgtGetNextRawPart( nRId) - end - elseif nInitialPosition == 4 then - local dDeltaYZ = EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimY() - EgtGetRawPartBBox( PARTS[nPart].idRaw):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 - local nRId = PARTS[nPart].idRaw - while nRId do - if bPreMove then EgtMoveRawPart( nRId, vtMove) end - EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, 90, -90)) - if not bPreMove then EgtMoveRawPart( nRId, vtMove) end - nRId = EgtGetNextRawPart( nRId) - end - end - + BeamLib.RotatePart( PARTS[nPart], nInitialPosition) + -- aggiunta lavorazioni in ultima fase MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 5cddb0a..11bd8a9 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -104,6 +104,49 @@ function BeamLib.AddPhaseWithRawParts( nRawId, OriXR, PosXR, dDeltaSucc) end end +------------------------------------------------------------------------------------------------------------- +--- funzione che ruota il pezzo, da lanciare per creare la disposizione corretta +function BeamLib.RotatePart( Part, nPosition) + -- primo posizionamento + if nPosition == 1 then + ; -- il pezzo è già in posizione + -- rotazione 90° + elseif nPosition == 2 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 + -- ruoto le travi della fase corrente + local nRId = Part.idRaw + while nRId do + if bPreMove then EgtMoveRawPart( nRId, vtMove) end + EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) + if not bPreMove then EgtMoveRawPart( nRId, vtMove) end + nRId = EgtGetNextRawPart( nRId) + end + -- rotazione 180° + elseif nPosition == 3 then + -- ribalto le travi della fase corrente + local nRId = Part.idRaw + while nRId do + EgtRotateRawPart( nRId, X_AX(), 180) + nRId = EgtGetNextRawPart( nRId) + end + -- rotazione 270° + elseif nPosition == 4 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 + -- ruoto le travi della fase corrente + local nRId = Part.idRaw + while nRId do + if bPreMove then EgtMoveRawPart( nRId, vtMove) end + EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, 90, -90)) + if not bPreMove then EgtMoveRawPart( nRId, vtMove) end + nRId = EgtGetNextRawPart( nRId) + end + end +end + ------------------------------------------------------------------------------------------------------------- function BeamLib.CreateOrEmptyAddGroup( PartId) -- recupero i dati del gruppo aggiuntivo diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 5276615..ffa6c84 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -546,12 +546,18 @@ function MachiningLib.AddOperations( vProc, Part, sRotation) local nDispId = EgtGetPhaseDisposition( nPhase) if sRotation == 'DOWN' then + local nRotation = EgtIf( Part.nInitialPosition <= 2, Part.nInitialPosition + 2, Part.nInitialPosition + 2 - 4) + BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'ROT', -2) EgtSetInfo( nDispId, 'TYPE', 'MID2') elseif sRotation == 'SIDE' then + local nRotation = EgtIf( Part.nInitialPosition <= 3, Part.nInitialPosition + 1, Part.nInitialPosition + 1 - 4) + BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'ROT', -1) EgtSetInfo( nDispId, 'TYPE', 'MID2') else + local nRotation = Part.nInitialPosition + BeamLib.RotatePart( Part, nRotation) EgtSetInfo( nDispId, 'TYPE', 'END') end EgtSetInfo( nDispId, 'ORD', MACHININGS[i].Proc.nIndexPartInParts)