diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index f2d7a39..bb38e0b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -554,12 +554,6 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b BD.OVM_BLADE_HBEAM = ( BD.OVM_BLADE_HBEAM or 11) BD.OVM_CHAIN_HBEAM = ( BD.OVM_CHAIN_HBEAM or 8) - -- se pretagli di coda sono attivi, aumento di 10mm la lunghezza del grezzo per fare effettivamente tagliare del materiale. - -- Altrimenti le lavorazioni pensano di essere nel vuoto e si muovono in rapido - if BD.PRECUT_TAIL and VerifyBigSectionCut( dRawW, dRawH) then - dRawL = dRawL + 10 - end - -- sovramateriale intermedio nullo se non definito dOvmMid = ( dOvmMid or 0) @@ -582,11 +576,6 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b -- salvo nota con lunghezza grezzo -- Recupero l'identificativo del gruppo di lavoro corrente local nMGrpId = EgtGetCurrMachGroup() - -- Lunghezza della barra - local dBarLen = EgtGetInfo( nMGrpId, 'BARLEN', 'd') - if not dBarLen then - EgtSetInfo( nMGrpId, 'BARLEN', dRawL) - end -- Area tavola local b3Tab = EgtGetTableArea() @@ -598,6 +587,18 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b -- Impostazione dell'attrezzaggio di default EgtImportSetup() + -- se pretagli di coda sono attivi, aumento di 10mm la lunghezza del grezzo per fare effettivamente tagliare del materiale. + -- Altrimenti le lavorazioni pensano di essere nel vuoto e si muovono in rapido + if BD.PRECUT_TAIL and VerifyBigSectionCut( dRawW, dRawH) then + dRawL = dRawL + 10 + end + + -- Lunghezza della barra + local dBarLen = EgtGetInfo( nMGrpId, 'BARLEN', 'd') + if not dBarLen then + EgtSetInfo( nMGrpId, 'BARLEN', dRawL) + end + -- Inserimento dei pezzi con il loro grezzo local Cnt = 0 local Len = dRawL @@ -880,6 +881,45 @@ local function ReorderTruncatingCuts( vProc, nPartId) return true end +------------------------------------------------------------------------------------------------------------- +-- mi assicuro che vengano rispettate le dipendenze tra le feature +local function ReorderFeatureWithDependency( vProc) + -- si riordina considerando le dipendenze con alcuni limiti: + -- * se ci sono dipendenze incrociate il risultato finale non è controllato ( A->B e B->C e C->A) + -- * se ci sono dipendenze opposte va in errore ( A->B e B->A) + + -- si sistemano le feature da lavorare prima + local i = 1 + local nMaxIter = ( #vProc * #vProc) + 1 + local nIter = 0 + while i <= #vProc do + nIter = nIter + 1 + if nIter > nMaxIter then + error( "UNEXPECTED ERROR ON DEPENDENCY") + end + + -- si controllano solo i fori + if Drill.Identify( vProc[i]) and vProc[i].Dependency and vProc[i].Dependency.ExecBefore and vProc[i].Dependency.ExecBefore.Id then + local nRefId = vProc[i].Dependency.ExecBefore.Id + local nRefIndex + + for j = 1, #vProc do + if i ~= j and vProc[j].Id == nRefId then + nRefIndex = j + break + end + end + + -- se il processo deve stare prima, ma ora è dopo + if nRefIndex and nRefIndex < i then + table.insert( vProc, nRefIndex, table.remove( vProc, i)) + i = max( nRefIndex - 1, 1) + end + end + i = i + 1 + end +end + ------------------------------------------------------------------------------------------------------------- local function OrderFeatures( vProc, b3Raw, nPartId) @@ -909,6 +949,13 @@ local function OrderFeatures( vProc, b3Raw, nPartId) if Hcut.Identify( B2) then return false end + -- se uno dipende dall'altro + if B1.Dependency and B1.Dependency.ExecBefore and B1.Dependency.ExecBefore.Id == B2.Id then + return true + end + if B2.Dependency and B2.Dependency.ExecBefore and B2.Dependency.ExecBefore.Id == B1.Id then + return false + end -- se uno di testa e non l'altro, privilegio quello di testa (a meno che non siano dei fori) if B1.Head ~= B2.Head and not Drill.Identify(B1) and not Drill.Identify(B2) then return B1.Head @@ -1202,6 +1249,9 @@ local function OrderFeatures( vProc, b3Raw, nPartId) end ReorderTruncatingCuts( vProc, nPartId) + + -- si riverificano feature con dipendenze + ReorderFeatureWithDependency( vProc) end ------------------------------------------------------------------------------------------------------------- @@ -2046,14 +2096,18 @@ local function SetDrillingsToMachineAfterHeadOrTailCut( vProc, vMachineBeforeInt if vDistHead and #vDistHead > 0 then -- verifico che il foro sia di testa if ( bOpen or ( not bOpen and vtExtr:getX() > 0 and vProc[i].Fcs ~= 0) or ( not bOpen and vtExtr:getX() < 0 and vProc[i].Fce ~= 0)) then - vProc[i].MachineAfterHeadCutId = vMachineBeforeIntersectingDrillings.Head.Id + if vProc[i].Dependency and vProc[i].Dependency.ExecAfter and vProc[i].Dependency.ExecAfter.Id == vMachineBeforeIntersectingDrillings.Head.Id then + vProc[i].MachineAfterHeadCutId = vMachineBeforeIntersectingDrillings.Head.Id + end vProc[i].Head = true end -- se esiste intersezione tra il foro e la feature di coda elseif vDistTail and #vDistTail > 0 then -- verifico che il foro sia di coda if ( bOpen or ( not bOpen and vtExtr:getX() < 0 and vProc[i].Fcs ~= 0) or ( not bOpen and vtExtr:getX() > 0 and vProc[i].Fce ~= 0)) then - vProc[i].MachineAfterTailCutId = vMachineBeforeIntersectingDrillings.Tail.Id + if vProc[i].Dependency and vProc[i].Dependency.ExecAfter and vProc[i].Dependency.ExecAfter.Id == vMachineBeforeIntersectingDrillings.Tail.Id then + vProc[i].MachineAfterTailCutId = vMachineBeforeIntersectingDrillings.Tail.Id + end vProc[i].Tail = true end end @@ -2061,6 +2115,7 @@ local function SetDrillingsToMachineAfterHeadOrTailCut( vProc, vMachineBeforeInt end end + ------------------------------------------------------------------------------------------------------------- local function AreDrillingsMirrored( Proc, ProcMirror, b3Raw) if Proc.Id == ProcMirror.Id then return false end @@ -2127,63 +2182,103 @@ end ------------------------------------------------------------------------------------------------------------- function GetFeatureInfoAndDependency( vProc, b3Raw, nPartId) - -- ciclo tutte le feature - for i = 1, #vProc do - local Proc = vProc[i] - -- calcolo topologia della feature - if NeedTopologyFeature( Proc) then - Topology.Classify( Proc, b3Raw) - -- se non richiesto, setto 'SPECIAL' - else - Proc.Topology = 'SPECIAL' - Proc.TopologyLongName = Proc.Topology - end - -- controllo la feature con tutte le altre per recuperare le dipendenze - for j = 1, #vProc do - local ProcB = vProc[j] - -- verifico se feature tipo LapJoint è attraversata da almeno un foro - if ( Proc.Topology == 'Pocket' or Proc.Topology == 'Tunnel' or Proc.Topology == 'Groove' or Mortise.Identify( Proc)) and Drill.Identify( ProcB) and Overlaps( Proc.Box, ProcB.Box) then - -- se foro in coda non setto la dipendenza - if not ProcB.AffectedFaces.Left then - Proc.PassedByHole = true - ProcB.Dependency = {} - ProcB.Dependency.ExecBefore = Proc - end + if vProc and #vProc > 0 and nPartId then + -- recupero ID per tagli troncanti testa e coda + local nHeadCuttingFeatureId = EgtGetInfo( nPartId, 'HEADCUTFEATUREID', 'i') or 0 + local nTailCuttingFeatureId = EgtGetInfo( nPartId, 'TAILCUTFEATUREID', 'i') or 0 + -- ciclo tutte le feature + for i = 1, #vProc do + local Proc = vProc[i] + -- calcolo topologia della feature + if NeedTopologyFeature( Proc) then + Topology.Classify( Proc, b3Raw) + -- se non richiesto, setto 'SPECIAL' + else + Proc.Topology = 'SPECIAL' + Proc.TopologyLongName = Proc.Topology end - -- verifico se feature tipo LapJoint è attraversata da almeno una mortasa a coda di rondine - if ( Proc.Topology == 'Pocket' or Proc.Topology == 'Tunnel' or Proc.Topology == 'Groove') - and DtMortise.SideIdentify( ProcB) and Overlaps( Proc.Box, ProcB.Box) and DtMortise.IsDeeper( ProcB, b3Raw) then - Proc.PassedByDtMortise = true - end - -- se tenone è attraversato da foro allora il foro deve essere fatto prima - if Tenon.Identify( Proc) and Drill.Identify( ProcB) and Overlaps( Proc.Box, ProcB.Box) then - Proc.PassedByHole = true - end - -- verifiche per specchiature - if BD.DOWN_HEAD or BD.TWO_EQUAL_HEADS then - -- forature - if BD.DOUBLE_HEAD_DRILLING and Drill.Identify( Proc) and Drill.Identify( ProcB) and not Proc.Mirror then - if AreDrillingsMirrored( Proc, ProcB, b3Raw) then - Proc.Mirror = ProcB + -- controllo la feature con tutte le altre per recuperare le dipendenze + for j = 1, #vProc do + -- non si controlla feature con sé stessa + if i ~= j then + local ProcB = vProc[j] + -- verifico se feature tipo LapJoint è attraversata da almeno un foro + if ( Proc.Topology == 'Pocket' or Proc.Topology == 'Tunnel' or Proc.Topology == 'Groove' or Mortise.Identify( Proc)) and Drill.Identify( ProcB) and Overlaps( Proc.Box, ProcB.Box) then + -- se foro in coda non setto la dipendenza + if not ProcB.AffectedFaces.Left then + Proc.PassedByHole = true + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + end + end + -- verifico se feature tipo LapJoint è attraversata da almeno una mortasa a coda di rondine + if ( Proc.Topology == 'Pocket' or Proc.Topology == 'Tunnel' or Proc.Topology == 'Groove') + and DtMortise.SideIdentify( ProcB) and Overlaps( Proc.Box, ProcB.Box) and DtMortise.IsDeeper( ProcB, b3Raw) then + Proc.PassedByDtMortise = true + end + -- se tenone è attraversato da foro allora il foro deve essere fatto prima + if Tenon.Identify( Proc) and Drill.Identify( ProcB) and Overlaps( Proc.Box, ProcB.Box) then + Proc.PassedByHole = true + end + -- se taglio attraversato da foro, si definisce precedenza in base ad angolo + if Drill.Identify( Proc) and Cut.Identify( ProcB) and Overlaps( Proc.Box, ProcB.Box) then + -- recupero e verifico l'entità foro + local DrillAuxId = ( EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0) + Proc.Id + local vtDrillExtr = EgtCurveExtrusion( DrillAuxId, GDB_RT.GLOB) + local bOpen = ( Proc.Fce ~= 0) and ( Proc.Fce ~= Proc.Fcs) + local ptCut, vtCutN = EgtSurfTmFacetCenter( ProcB.Id, 0, GDB_ID.ROOT) + local dMaxAngleDrillOnCut = BD.MAX_ANGLE_DRILL_CUT or 10 + if GetAngle( vtDrillExtr, vtCutN) > dMaxAngleDrillOnCut then + if bOpen and GetAngle( -vtDrillExtr, vtCutN) < dMaxAngleDrillOnCut then + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + Proc.Dependency = {} + Proc.Dependency.ExecAfter = ProcB + else + Proc.Dependency = {} + Proc.Dependency.ExecBefore = ProcB + ProcB.Dependency = {} + ProcB.Dependency.ExecAfter = Proc + end + else + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + Proc.Dependency = {} + Proc.Dependency.ExecAfter = ProcB + end + end + -- verifiche per specchiature + if BD.DOWN_HEAD or BD.TWO_EQUAL_HEADS then + -- forature + if BD.DOUBLE_HEAD_DRILLING and Drill.Identify( Proc) and Drill.Identify( ProcB) and not Proc.Mirror then + if AreDrillingsMirrored( Proc, ProcB, b3Raw) then + Proc.Mirror = ProcB + end + end + end + -- verifiche per tagli troncanti testa e coda: devono sempre essere subito dopo il taglio di testa e il taglio di coda, rispettivamente + if Proc.Prc == 340 and ProcB == nHeadCuttingFeatureId then + Proc.Dependency = {} + Proc.Dependency.ExecBefore = ProcB + elseif Proc == nHeadCuttingFeatureId and ProcB.Prc == 340 then + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + elseif Proc.Prc == 350 and ProcB == nTailCuttingFeatureId then + Proc.Dependency = {} + Proc.Dependency.ExecBefore = ProcB + elseif Proc == nTailCuttingFeatureId and ProcB.Prc == 350 then + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + end + -- se una feature deve essere lavorata prima dei tagli troncanti, si setta che non esiste taglio troncante + if Proc.Dependency and Proc.Dependency.ExecBefore and Proc.Dependency.ExecBefore.Id == nHeadCuttingFeatureId then + -- EgtRemoveInfo( nPartId, 'HEADCUTFEATUREID') + end + if Proc.Dependency and Proc.Dependency.ExecBefore and Proc.Dependency.ExecBefore.Id == nTailCuttingFeatureId then + -- EgtRemoveInfo( nPartId, 'TAILCUTFEATUREID') end end end - -- verifiche per tagli troncanti testa e coda: devono sempre essere subito dopo il taglio di testa e il taglio di coda, rispettivamente - local nHeadCuttingFeatureId = EgtGetInfo( nPartId, 'HEADCUTFEATUREID', 'i') - local nTailCuttingFeatureId = EgtGetInfo( nPartId, 'TAILCUTFEATUREID', 'i') - if Proc.Prc == 340 and ProcB == nHeadCuttingFeatureId then - Proc.Dependency = {} - Proc.Dependency.ExecBefore = ProcB - elseif Proc == nHeadCuttingFeatureId and ProcB.Prc == 340 then - ProcB.Dependency = {} - ProcB.Dependency.ExecBefore = Proc - elseif Proc.Prc == 350 and ProcB == nTailCuttingFeatureId then - Proc.Dependency = {} - Proc.Dependency.ExecBefore = ProcB - elseif Proc == nTailCuttingFeatureId and ProcB.Prc == 350 then - ProcB.Dependency = {} - ProcB.Dependency.ExecBefore = Proc - end end end end diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 5dd095e..508dd28 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -527,6 +527,17 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dMaxDepth = min( dMaxDepth, max( dToolFreeLen - dSubL, 0)) -- Verifico inclinazione foro nei limiti local bTryDrill = EgtIf( dMaxDepth > 0, ( CosB < BD.DRILL_VX_MAX), false) + -- se il foro deve essere eseguito dopo un taglio, potrebbe essere perchè il taglio crea una superficie perpendicolare + if Proc.Dependency and Proc.Dependency.ExecAfter then + local ptCut, vtCutN = EgtSurfTmFacetCenter( Proc.Dependency.ExecAfter.Id, 0, GDB_ID.ROOT) + local dMaxAngleDrillOnCut = BD.MAX_ANGLE_DRILL_CUT or 10 + local dAngle = GetAngle( vtExtr, vtCutN) + CosB = cos( dAngle) + if dAngle < dMaxAngleDrillOnCut then + -- controllo di essere nei limiti + bTryDrill = true + end + end if ( CosB > 0.8 * BD.DRILL_VX_MAX and CosB < BD.DRILL_VX_MAX_ANGLEDRILL) then -- cerco le forature speciali AngleDrill local sDrilling3, sType3, dMaxDepth3 = ML.FindAngleDrilling( dDiam, dCheckDepth, bDrillUp, bDrillDown) diff --git a/UpdateLog.txt b/UpdateLog.txt index efb44f3..e8e06e1 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -1,7 +1,11 @@ ==== Beam Update Log ==== +Versione 2.7l3 (23/12/2025) +- Modif : nei fori che attraversano un taglio si decide la precedenza in base all'angolo tra foro e taglio stesso +- Fixed : corretto precut in caso di sega a catena + Versione 2.7l2 (16/12/2025) -- Added : in LapJoint pulizia spigoli con fresa a V su tasche passanti +- Added : in LapJoint pulizia spigoli con fresa a V su tasche non passanti Versione 2.7l1 (10/12/2025) - Added : in LapJoint aggiunta gestione fresatura con aggregato flottante (Q specifica) diff --git a/Version.lua b/Version.lua index 71d9449..2978017 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Beam NAME = 'Beam' -VERSION = '2.7l2' +VERSION = '2.7l3' MIN_EXE = '2.7f2'