Corretta gestione rotazione pezzo nel DISP in caso che la soluzione scelta sia una prerotazione

This commit is contained in:
andrea.villa
2024-11-18 15:29:32 +01:00
parent 5aa2b5ac4d
commit 7e6d8f4172
3 changed files with 58 additions and 55 deletions
+9 -55
View File
@@ -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')
+43
View File
@@ -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
+6
View File
@@ -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)