- Correzione posizione pezzi in caso di split con rotazione del pezzo singolo
- Correzione rotazioni del pezzo quando c'è pre-rotazione
This commit is contained in:
+37
-30
@@ -983,9 +983,14 @@ end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- esegue le strategie migliori che ha precedentemente scelto
|
||||
local function CalculateMachinings( vProc, Part)
|
||||
local function CalculateMachinings( vProc, Part, nInitialRotation)
|
||||
local bAreAllApplyOk = true
|
||||
local CurrRotation = 1
|
||||
local n0Rotation = nInitialRotation
|
||||
local n90Rotation = nInitialRotation + 1
|
||||
if n90Rotation > 4 then n90Rotation = n90Rotation - 4 end
|
||||
local n180Rotation = nInitialRotation + 2
|
||||
if n180Rotation > 4 then n180Rotation = n180Rotation - 4 end
|
||||
local nCurrRotation = 1
|
||||
-- applico le strategie scelte
|
||||
for i = 1, #vProc do
|
||||
-- processo tutte le feature attive applicando le lavorazioni
|
||||
@@ -993,20 +998,19 @@ local function CalculateMachinings( vProc, Part)
|
||||
-- se la feature deve essere processata
|
||||
if Proc.nFlg ~= 0 then
|
||||
-- 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 and not( Proc.bSide) and not( Proc.bDown) then
|
||||
BeamLib.RotatePart( Part, 1 - CurrRotation)
|
||||
CurrRotation = 1
|
||||
if Proc.bDown and nCurrRotation ~= n180Rotation then
|
||||
BeamLib.RotatePart( Part, n180Rotation - nCurrRotation)
|
||||
nCurrRotation = n180Rotation
|
||||
elseif Proc.bSide and nCurrRotation ~= n90Rotation then
|
||||
BeamLib.RotatePart( Part, n90Rotation - nCurrRotation)
|
||||
nCurrRotation = n90Rotation
|
||||
elseif nCurrRotation ~= n0Rotation and not( Proc.bSide) and not( Proc.bDown) then
|
||||
BeamLib.RotatePart( Part, n0Rotation - nCurrRotation)
|
||||
nCurrRotation = n0Rotation
|
||||
end
|
||||
-- aggiorno info pezzo
|
||||
Part.b3Raw = EgtGetRawPartBBox( Part.idRaw)
|
||||
Part.b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Part.id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
|
||||
-- si applicano le strategie
|
||||
if Proc.ChosenStrategy then
|
||||
-- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia)
|
||||
@@ -1023,12 +1027,11 @@ local function CalculateMachinings( vProc, Part)
|
||||
end
|
||||
|
||||
-- ripristino pezzo in posizione originale
|
||||
if CurrRotation ~= 1 then
|
||||
BeamLib.RotatePart( Part, 1 - CurrRotation)
|
||||
if nCurrRotation ~= 1 then
|
||||
BeamLib.RotatePart( Part, 1 - nCurrRotation)
|
||||
-- aggiorno info pezzo
|
||||
Part.b3Raw = EgtGetRawPartBBox( Part.idRaw)
|
||||
Part.b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Part.id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
CurrRotation = 1
|
||||
end
|
||||
return MACHININGS, bAreAllApplyOk
|
||||
end
|
||||
@@ -1391,32 +1394,35 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
local bIsCombinationMachinable = false
|
||||
local vProc, MatrixResult
|
||||
while not bIsCombinationMachinable do
|
||||
local bAllStrategiesApplied = false
|
||||
-- si calcola la combinazione di lavorazione migliore
|
||||
vProc, MatrixResult = GetBestResultFromCombinationsMatrix( PROCESSINGS[nPart], PARTS[nPart])
|
||||
|
||||
-- salvo sul PART la posizione di partenza che è stata scelta
|
||||
PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition
|
||||
|
||||
-- debug
|
||||
if EgtGetDebugLevel() >= 1 then
|
||||
PrintFeatures( vProc, PARTS[nPart])
|
||||
end
|
||||
EgtOutLog( ' *** AddMachinings ***', 1)
|
||||
|
||||
-- ordinamento di base delle feature
|
||||
vProc = OrderFeatures( vProc)
|
||||
|
||||
-- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale
|
||||
local bAllStrategiesApplied = false
|
||||
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProc, PARTS[nPart])
|
||||
bIsCombinationMachinable = bAllStrategiesApplied
|
||||
|
||||
|
||||
-- se la posizione iniziale non è calcolata, significa che non ci sono feature da eseguire. Solo taglio testa/coda
|
||||
if not MatrixResult.nInitialPosition then
|
||||
MatrixResult.nInitialPosition = 1
|
||||
MACHININGS.Info.nHeadCutRotation = 1
|
||||
MACHININGS.Info.nSplitCutRotation = 1
|
||||
-- sltrimenti si fanno tutti i calcoli
|
||||
else
|
||||
-- salvo sul PART la posizione di partenza che è stata scelta
|
||||
PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition
|
||||
|
||||
-- ordinamento di base delle feature
|
||||
vProc = OrderFeatures( vProc)
|
||||
|
||||
-- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale
|
||||
bAllStrategiesApplied = false
|
||||
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProc, PARTS[nPart], PARTS[nPart].nInitialPosition)
|
||||
bIsCombinationMachinable = bAllStrategiesApplied
|
||||
end
|
||||
|
||||
-- aggiunge tagli testa e coda in fasi opportune
|
||||
local nRotHeadCut = MatrixResult.nInitialPosition + MACHININGS.Info.nHeadCutRotation - 1
|
||||
if nRotHeadCut > 4 then
|
||||
@@ -1444,7 +1450,8 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc])
|
||||
table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc])
|
||||
|
||||
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProcHeadTail, PARTS[nPart])
|
||||
bAllStrategiesApplied = false
|
||||
MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProcHeadTail, PARTS[nPart], PARTS[nPart].nInitialPosition)
|
||||
bIsCombinationMachinable = bIsCombinationMachinable and bAllStrategiesApplied
|
||||
end
|
||||
|
||||
@@ -1488,7 +1495,7 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
if MatrixResult.bSomeFeatureSide then
|
||||
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
|
||||
if MatrixResult.bSomeFeatureDown then
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, EgtIf( bSplitAlreadyExecuted, BeamData.RAW_OFFSET, 0))
|
||||
nPhase = EgtGetCurrPhase()
|
||||
nDispId = EgtGetPhaseDisposition( nPhase)
|
||||
EgtSetInfo( nDispId, 'ORD', nOrd)
|
||||
@@ -1509,7 +1516,7 @@ function BeamExec.ProcessMachinings( PARTS)
|
||||
|
||||
-- se ci sono state lavorazioni in rotazione precedente devo creare altra fase. Altrimenti già creata da prima
|
||||
if MatrixResult.bSomeFeatureDown or MatrixResult.bSomeFeatureSide then
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, 0)
|
||||
BeamLib.AddPhaseWithRawParts( PARTS[nPart].idRaw, BeamData.ptOriXR, BeamData.dPosXR, EgtIf( bSplitAlreadyExecuted, BeamData.RAW_OFFSET, 0))
|
||||
nPhase = EgtGetCurrPhase()
|
||||
nDispId = EgtGetPhaseDisposition( nPhase)
|
||||
EgtSetInfo( nDispId, 'ORD', nOrd)
|
||||
|
||||
@@ -772,14 +772,15 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
|
||||
local nDispId = EgtGetPhaseDisposition( nPhase)
|
||||
|
||||
if sRotation == 'DOWN' then
|
||||
BeamLib.RotatePart( Part, 2)
|
||||
BeamLib.RotatePart( Part, Part.nInitialPosition - 3)
|
||||
EgtSetInfo( nDispId, 'ROT', -2)
|
||||
EgtSetInfo( nDispId, 'TYPE', 'MID2')
|
||||
elseif sRotation == 'SIDE' then
|
||||
BeamLib.RotatePart( Part, 1)
|
||||
BeamLib.RotatePart( Part, Part.nInitialPosition - 2)
|
||||
EgtSetInfo( nDispId, 'ROT', -1)
|
||||
EgtSetInfo( nDispId, 'TYPE', 'MID2')
|
||||
else
|
||||
BeamLib.RotatePart( Part, Part.nInitialPosition - 1)
|
||||
EgtSetInfo( nDispId, 'TYPE', 'END')
|
||||
end
|
||||
EgtSetInfo( nDispId, 'ORD', MACHININGS[i].Proc.nIndexPartInParts)
|
||||
|
||||
Reference in New Issue
Block a user