diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index d64f244..e5f72ab 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -694,13 +694,7 @@ if bToProcess then BeamExec.GetProcessings( PARTS, BEAM.FLAG == 10) BeamExec.GetCombinationMatrix( PARTS, BEAM.FLAG == 10) - BeamExec.ProcessMachinings( PARTS) - - -- scrittura variabili globali per interfaccia - if BEAM.FLAG == 10 then - BEAM.PREROTATE90 = PARTS[1].nInitialPosition - 1 - BEAM.PREINVERT = EgtIf( PARTS[1].bPartInCombiIsInverted, 1, 0) - end + BeamExec.ProcessMachinings( PARTS, BEAM.FLAG == 10) local sOutput = '' @@ -727,7 +721,7 @@ if bToProcess then BEAM.ERR = 0 BEAM.MSG = '---' end - BEAM.ROT = -( RESULT[i].nRotation or 1) + 1 + BEAM.ROT = -( ( RESULT[i].nRotation - ( BEAM.PREROTATE90 or 0)) or 1) + 1 BEAM.CUTID = RESULT[i].idCut BEAM.TASKID = RESULT[i].idTask WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) @@ -743,7 +737,7 @@ if bToProcess then sOutput = sOutput .. string.format( '[%d,%d] %s\n', RESULT[i].idCut, RESULT[i].idTask, sMsg) BEAM.ERR = 19 BEAM.MSG = sMsg - BEAM.ROT = -( RESULT[i].nRotation or 1) + 1 + BEAM.ROT = -( ( RESULT[i].nRotation - ( BEAM.PREROTATE90 or 0)) or 1) + 1 BEAM.CUTID = RESULT[i].idCut BEAM.TASKID = RESULT[i].idTask WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) @@ -769,7 +763,7 @@ if bToProcess then sOutput = sOutput .. string.format( '[%d,%d] %s\n', RESULT[i].idCut, RESULT[i].idTask, sMsg) BEAM.ERR = -19 BEAM.MSG = 'Incomplete : Completion index ' .. RESULT[i].ChosenStrategy.dCompletionIndex .. '/5\n' .. sMsg - BEAM.ROT = -( RESULT[i].nRotation or 1) + 1 + BEAM.ROT = -( ( RESULT[i].nRotation - ( BEAM.PREROTATE90 or 0)) or 1) + 1 BEAM.CUTID = RESULT[i].idCut BEAM.TASKID = RESULT[i].idTask WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) diff --git a/FlipRot.lua b/FlipRot.lua index 988f70c..b1164d7 100644 --- a/FlipRot.lua +++ b/FlipRot.lua @@ -145,7 +145,7 @@ local function MyProcessFeatures() BeamExec.GetProcessings( PARTS, true) BeamExec.GetCombinationMatrix( PARTS, true) - BeamExec.ProcessMachinings( PARTS) + BeamExec.ProcessMachinings( PARTS, true) -- scrittura variabili globali per interfaccia BEAM.PREROTATE90 = PARTS[1].nInitialPosition - 1 diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 6c27d39..d0d2452 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1614,7 +1614,7 @@ function BeamExec.GetCombinationMatrix( PARTS, bIsFlipRot) end ------------------------------------------------------------------------------------------------------------- -function BeamExec.ProcessMachinings( PARTS) +function BeamExec.ProcessMachinings( PARTS, bIsFlipRot) -- ciclo sui pezzi local nTotErr = 0 local Stats = {} @@ -1711,8 +1711,6 @@ function BeamExec.ProcessMachinings( PARTS) MACHININGS.Info.nSplitCutRotation = 1 end end - -- salvo sul PART la posizione di partenza che è stata scelta - PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition local nOffsetIndex = EgtIf( PARTS[nPart].bPartInCombiIsInverted, 4, 0) -- aggiunge tagli testa e coda in fasi opportune @@ -1720,36 +1718,34 @@ function BeamExec.ProcessMachinings( PARTS) if nRotHeadCut > 4 then nRotHeadCut = nRotHeadCut - 4 end - nRotHeadCut = nRotHeadCut + nOffsetIndex local nRotSplitCut = MatrixResult.nInitialPosition + MACHININGS.Info.nSplitCutRotation - 1 if nRotSplitCut > 4 then nRotSplitCut = nRotSplitCut - 4 end - nRotSplitCut = nRotSplitCut + nOffsetIndex -- setto nella Proc l'indice rotazione nella quale deve essere lavorata - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut -- si imposta flag rotazione per taglio di testa if MACHININGS.Info.nHeadCutRotation == 2 then - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bSide = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bSide = true elseif MACHININGS.Info.nHeadCutRotation == 3 then - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bDown = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bDown = true else - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bStd = true end -- si imposta flag rotazione per taglio di coda if MACHININGS.Info.nSplitCutRotation == 2 then - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bSide = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bSide = true elseif MACHININGS.Info.nSplitCutRotation == 3 then - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bDown = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bDown = true else - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bStd = true end local vProcHeadTail = {} - table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc]) - table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc]) + table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc]) + table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc]) MACHININGS = CalculateMachinings( vProcHeadTail, PARTS[nPart], MatrixResult.nInitialPosition) @@ -1772,6 +1768,44 @@ function BeamExec.ProcessMachinings( PARTS) nRawId = EgtGetNextRawPart( nRawId) end + + local nInitialPosition = MatrixResult.nInitialPosition + -- PREROTAZIONE PEZZO + if MatrixResult.nInitialPosition ~= 1 or PARTS[nPart].bPartInCombiIsInverted then + -- si toglie il pezzo dal grezzo per poter fare operazioni + EgtRemovePartFromRawPart( PARTS[nPart].id) + + -- salvo situazione precedente su lista BEAM ( scrittura variabili globali per interfaccia) + if bIsFlipRot then + BEAM.PREROTATE90 = MatrixResult.nInitialPosition - 1 + BEAM.PREINVERT = EgtIf( PARTS[nPart].bPartInCombiIsInverted, 1, 0) + end + + -- se c'è stata inversione, si inverte il pezzo anche in disegna + if PARTS[nPart].bPartInCombiIsInverted then + local ptInv = PARTS[nPart].b3PartOriginal:getMin() + Vector3d( PARTS[nPart].b3PartOriginal:getDimX() / 2, PARTS[nPart].b3PartOriginal:getDimY() / 2, 0) + EgtRotate( PARTS[nPart].id, ptInv, Z_AX(), 180, GDB_RT.GLOB) + PARTS[nPart].bIsInverted = true + end + + -- se c'è una prerotazione, si inverte il pezzo + if MatrixResult.nInitialPosition ~= 1 then + local ptRot = PARTS[nPart].b3PartOriginal:getMin() + Vector3d( 0, PARTS[nPart].b3PartOriginal:getDimY() / 2, PARTS[nPart].b3PartOriginal:getDimZ() / 2) + local nRotationDeg = 90 * ( MatrixResult.nInitialPosition - 1) + EgtRotate( PARTS[nPart].id, ptRot, X_AX(), nRotationDeg, GDB_RT.GLOB) + end + + -- si rimette il pezzo nel grezzo + EgtAddPartToRawPart( PARTS[nPart].id, {0,0,0}, PARTS[nPart].idRaw) + + -- dico che il pezzo originale è nella posizione iniziale come arriva da BTL ( è stato appena ruotato qui sopra) + nInitialPosition = 1 + end + + -- salvo sul PART la posizione di partenza che è stata scelta + PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition + + local bAreAllMachiningApplyOk local sErr local bSplitAlreadyExecuted = false @@ -1785,7 +1819,6 @@ function BeamExec.ProcessMachinings( PARTS) -- creazione effettiva delle lavorazioni MACHININGS.Info = {} local nCurrPosition = 1 - local nInitialPosition = MatrixResult.nInitialPosition -- se c'è almeno una lavorazione in posizionamento con trave ribaltata if MatrixResult.bSomeFeatureDown then local nRotation = EgtIf( nInitialPosition + 2 > 4, nInitialPosition + 2 - 4, nInitialPosition + 2) @@ -1862,6 +1895,8 @@ function BeamExec.ProcessMachinings( PARTS) if PARTS[nPart].bPartInCombiIsInverted then BeamLib.InvertRawPart( PARTS[nPart], -2) end + -- ripristino anche eventuali pre-rotazioni + nInitialPosition = nInitialPosition + ( BEAM.PREROTATE90 or 0) -- si ribalta il pezzo in posizione iniziale BeamLib.RotateRawPart( PARTS[nPart], 1 - nInitialPosition) else @@ -2090,48 +2125,46 @@ function BeamExec.ProcessAlternatives( PARTS) if nRotHeadCut > 4 then nRotHeadCut = nRotHeadCut - 4 end - nRotHeadCut = nRotHeadCut + nOffsetIndex local nRotSplitCut = MatrixResult.nInitialPosition + MACHININGS.Info.nSplitCutRotation - 1 if nRotSplitCut > 4 then nRotSplitCut = nRotSplitCut - 4 end - nRotSplitCut = nRotSplitCut + nOffsetIndex -- setto nella Proc l'indice rotazione nella quale deve essere lavorata - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].nIndexRotation = nRotHeadCut + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].nIndexRotation = nRotSplitCut -- si imposta flag rotazione per taglio di testa if MACHININGS.Info.nHeadCutRotation == 2 then - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bDown = nil - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bSide = true - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bDown = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bSide = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bStd = nil elseif MACHININGS.Info.nHeadCutRotation == 3 then - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bDown = true - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bSide = nil - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bDown = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bSide = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bStd = nil else - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bDown = nil - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bSide = nil - PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc].bStd = true + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bDown = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bSide = nil + PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc].bStd = true end -- si imposta flag rotazione per taglio di coda if MACHININGS.Info.nSplitCutRotation == 2 then - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bDown = nil - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bSide = true - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bDown = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bSide = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bStd = nil elseif MACHININGS.Info.nSplitCutRotation == 3 then - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bDown = true - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bSide = nil - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bDown = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bSide = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bStd = nil else - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bDown = nil - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bSide = nil - PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc].bStd = true + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bDown = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bSide = nil + PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc].bStd = true end local vProcHeadTail = {} - table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut][MatrixResult.nIndexHeadCutInVProc]) - table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc]) + table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotHeadCut+nOffsetIndex][MatrixResult.nIndexHeadCutInVProc]) + table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut+nOffsetIndex][MatrixResult.nIndexTailCutInVProc]) MACHININGS = CalculateMachinings( vProcHeadTail, PARTS[nPart], MatrixResult.nInitialPosition) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 65a6e7b..8217ef6 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1442,18 +1442,20 @@ function MachiningLib.AddOperations( MACHININGS, Part, sRotation) local nPhase = EgtGetCurrPhase() local idDisp = EgtGetPhaseDisposition( nPhase) + -- posizione iniziale considerando eventuiali prerotazioni + local nRealInitialPosition = Part.nInitialPosition - ( BEAM.PREROTATE90 or 0) if sRotation == 'DOWN' then - local nRotation = EgtIf( Part.nInitialPosition + 2 > 4, Part.nInitialPosition + 2 - 4, Part.nInitialPosition + 2) - 1 + local nRotation = EgtIf( nRealInitialPosition + 2 > 4, nRealInitialPosition + 2 - 4, nRealInitialPosition + 2) - 1 BeamLib.RotateRawPart( Part, nRotation) EgtSetInfo( idDisp, 'ROT', -2) EgtSetInfo( idDisp, 'TYPE', 'MID2') elseif sRotation == 'SIDE' then - local nRotation = EgtIf( Part.nInitialPosition + 1 > 4, Part.nInitialPosition + 1 - 4, Part.nInitialPosition + 1) - 1 + local nRotation = EgtIf( nRealInitialPosition + 1 > 4, nRealInitialPosition + 1 - 4, nRealInitialPosition + 1) - 1 BeamLib.RotateRawPart( Part, nRotation) EgtSetInfo( idDisp, 'ROT', -1) EgtSetInfo( idDisp, 'TYPE', 'MID2') else - local nRotation = Part.nInitialPosition - 1 + local nRotation = nRealInitialPosition - 1 BeamLib.RotateRawPart( Part, nRotation) EgtSetInfo( idDisp, 'TYPE', 'END') end diff --git a/Process.lua b/Process.lua index 344415e..e5f75a9 100644 --- a/Process.lua +++ b/Process.lua @@ -304,7 +304,7 @@ local function MyProcessFeatures() BeamExec.GetProcessings( PARTS, false) BeamExec.GetCombinationMatrix( PARTS, false) - BeamExec.ProcessMachinings( PARTS) + BeamExec.ProcessMachinings( PARTS, false) local nErrCnt = 0 local nWarnCnt = 0 local sOutput = ''