From b5cb706ad5588f030b7b72af2e3a7f73deb45d50 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Wed, 10 Jun 2026 15:02:29 +0200 Subject: [PATCH 1/5] Aggiunto controllo su massima lunghezza pezzo processabile --- BatchProcessNew.lua | 18 ++++++++++++++++++ Process.lua | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 1fff59b..31cd284 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -388,6 +388,15 @@ if bToProcess then else PARTS[i].b3PartOriginal = b3Solid end + if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + local sOut = 'Piece-Length (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. + 'out of machine limits (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + BEAM.ERR = 17 + BEAM.MSG = sOut + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + PostErrView( BEAM.ERR, BEAM.MSG) + return + end end -- Assegno lunghezza della barra dBarLen = PARTS[1].b3PartOriginal:getDimX() + 10 @@ -447,6 +456,15 @@ if bToProcess then else PARTS[i].b3PartOriginal = b3Solid end + if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + local sOut = 'Piece-Length (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. + 'out of machine limits (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + BEAM.ERR = 17 + BEAM.MSG = sOut + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + PostErrView( BEAM.ERR, BEAM.MSG) + return + end end end diff --git a/Process.lua b/Process.lua index e5f75a9..1f9413f 100644 --- a/Process.lua +++ b/Process.lua @@ -131,6 +131,14 @@ local function MyProcessInputData() else PARTS[i].b3PartOriginal = b3Solid end + if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + local sOut = 'Lunghezza (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. + 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + EgtOutLog( sOut) + EgtOutBox( sOut, 'Lavora Travi', 'WARNING') + EgtDraw() + return false + end end dRawW = PARTS[1].b3PartOriginal:getDimY() dRawH = PARTS[1].b3PartOriginal:getDimZ() From eec6b50985ae304e08b0be4dbec06efedf6d3100 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 10 Jun 2026 18:15:17 +0200 Subject: [PATCH 2/5] - in BLADETOWASTE.CalculateDiceMachinings si calcola il grezzo dinamico per la presimulazione. Da completare e gestire in presimulazione --- StrategyLibs/BLADETOWASTE.lua | 70 ++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 750d6d3..9bbb30d 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -782,6 +782,46 @@ local function CutWholeWaste( Proc, Part, OptionalParameters) end +local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, MainFace, OtherFace) + + -- frame solidale alla feature + local vtZ = MainFace.vtN + local vtX = OtherFace and OtherFace.vtN or nil + local frMainFace = Frame3d( MainFace.ptCenter, vtZ, vtX) + + -- box del cubetto in riferimento feature + local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) + local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) + b3Surf:Add( b3SurfPerpendicular) + + -- estensione box per non avere problemi nella sottrazione booleana + if OtherFace then + local vtY = vtZ ^ vtX + local ptDeltaX = b3Surf:getMax() + vtX * 1 + local ptDeltaZ = b3Surf:getMax() + vtZ * 1 + local ptDeltaYplus = b3Surf:getMax() + vtY * 1 + local ptDeltaYminus = b3Surf:getMin() - vtY * 1 + b3Surf:Add( ptDeltaX) + b3Surf:Add( ptDeltaZ) + b3Surf:Add( ptDeltaYplus) + b3Surf:Add( ptDeltaYminus) + else + b3Surf:expand( 1) + end + + -- si porta il box in riferimento globale + b3Surf:toGlob( frMainFace) + + -- conversione box cubetto in superficie + local idSurfTmToSubtract = EgtSurfTmBBox( Part.idTempGroup, b3Surf, false, GDB_RT.GLOB) + + -- sottrazione del cubetto dal grezzo + EgtSurfTmSubtract( idRaw, idSurfTmToSubtract) + + return idRaw +end + + local function CalculateDiceMachinings( vCuts, Parameters) local Machinings = {} local bMoveAfterSplit = false @@ -789,6 +829,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) local Proc = Parameters.Proc local Part = Parameters.Part local MainFace = Parameters.MainFace + local OtherFace = next( Parameters.OtherFace) and Parameters.OtherFace or nil local Tool = Parameters.Tool local sChosenBladeType = Parameters.sChosenBladeType local dExtendAfterTail = Parameters.dExtendAfterTail @@ -797,21 +838,15 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bCannotSplitRestLength = Parameters.bCannotSplitRestLength local bReduceDiceDepth = Parameters.bReduceDiceDepth + -- trimesh con RestLength + local b3CheckCollision = BeamLib.GetPartBoxWithHeadTail( Part, sRestLengthSideForPreSimulation) + local idCheckCollisionTm = EgtSurfTmBBox( Part.idTempGroup, b3CheckCollision, false, GDB_RT.GLOB) + -- eventuale inversione tagli ortogonali e aggiunta informazioni alla geometria local bAreOrthogonalCutsInverted = false for i = 1, #vCuts do for j = 1, #vCuts[i] do SetDiceFaceInfo( Proc, vCuts[i][j]) - -- TODO vedere se questa parte serve ancora; in teoria no perchè il taglio è girato automaticamente nella FaceByBlade - -- if ( i % 2) == 1 then - -- local vtO = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) - -- if MachiningLib.IsFaceZOutOfRange( vtO, Tool) then - -- EgtInvertSurf( vCuts[i][j]) - -- local vtCurrentFaceNormal = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) - -- EgtMove( vCuts[i][j], -vtCurrentFaceNormal * Tool.dThickness, GDB_RT.GLOB) - -- bAreOrthogonalCutsInverted = true - -- end - -- end end end -- calcolo lavorazioni @@ -857,8 +892,8 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bIsDicingOk = true if bCanMergeParallelCuts then local nAddGrpId = BeamLib.GetAddGroup( Part.id) - local nSurfToCut = EgtSurfTmBySewing( nAddGrpId, vCuts[i], false) - local ProcTrimesh = FeatureLib.GetProcFromTrimesh( nSurfToCut, Part) + local idSurfToCut = EgtSurfTmBySewing( nAddGrpId, vCuts[i], false) + local ProcTrimesh = FeatureLib.GetProcFromTrimesh( idSurfToCut, Part) local OptionalParametersCutWholeWaste = { nToolIndex = Tool.nIndex, @@ -877,8 +912,12 @@ local function CalculateDiceMachinings( vCuts, Parameters) bMoveAfterSplit = true end end + -- aggiornamento grezzo dinamico + if i % 2 == 0 then + UpdateDiceRaw( idCheckCollisionTm, idSurfToCut, vCuts[i-1][#vCuts[i-1]], Part, MainFace, OtherFace) + end else - EgtErase( nSurfToCut) + EgtErase( idSurfToCut) bIsDicingOk = false end end @@ -936,6 +975,10 @@ local function CalculateDiceMachinings( vCuts, Parameters) if Cutting.sStage == 'AfterTail' then bMoveAfterSplit = true end + -- aggiornamento grezzo dinamico + if i % 2 == 0 then + UpdateDiceRaw( idCheckCollisionTm, vCuts[i][j], vCuts[i-1][j], Part, MainFace, OtherFace) + end end end end @@ -1013,6 +1056,7 @@ local function CutWithDicing( Proc, Part, OptionalParameters) Proc = Proc, Part = Part, MainFace = Face1, + OtherFace = Face2, Tool = TOOLS[nToolIndex], sChosenBladeType = sChosenBladeType, dExtendAfterTail = dExtendAfterTail, From fb3a5ec0be1909f52c6d20934bee508ff13a634f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 10 Jun 2026 18:21:08 +0200 Subject: [PATCH 3/5] - in Process e BatchProcessNew piccola correzione --- BatchProcessNew.lua | 8 ++++---- Process.lua | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 31cd284..03811b7 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -388,9 +388,9 @@ if bToProcess then else PARTS[i].b3PartOriginal = b3Solid end - if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + if BeamData.MAX_LENGTH and BeamData.MAX_LENGTH > 10 and b3Solid:getDimX() > BeamData.MAX_LENGTH then local sOut = 'Piece-Length (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. - 'out of machine limits (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + 'out of machine limits (' .. EgtNumToString( BeamData.MAX_LENGTH, 2) .. ') ' BEAM.ERR = 17 BEAM.MSG = sOut WriteErrToLogFile( BEAM.ERR, BEAM.MSG) @@ -456,9 +456,9 @@ if bToProcess then else PARTS[i].b3PartOriginal = b3Solid end - if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + if BeamData.MAX_LENGTH and BeamData.MAX_LENGTH > 10 and b3Solid:getDimX() > BeamData.MAX_LENGTH then local sOut = 'Piece-Length (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. - 'out of machine limits (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + 'out of machine limits (' .. EgtNumToString( BeamData.MAX_LENGTH, 2) .. ') ' BEAM.ERR = 17 BEAM.MSG = sOut WriteErrToLogFile( BEAM.ERR, BEAM.MSG) diff --git a/Process.lua b/Process.lua index 1f9413f..0baf585 100644 --- a/Process.lua +++ b/Process.lua @@ -131,9 +131,9 @@ local function MyProcessInputData() else PARTS[i].b3PartOriginal = b3Solid end - if BD.MAX_LENGTH and BD.MAX_LENGTH > 10 and b3Solid:getDimX() > BD.MAX_LENGTH then + if BeamData.MAX_LENGTH and BeamData.MAX_LENGTH > 10 and b3Solid:getDimX() > BeamData.MAX_LENGTH then local sOut = 'Lunghezza (' .. EgtNumToString( b3Solid:getDimX(), 2) .. ') ' .. - 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_LENGTH, 2) .. ') ' + 'oltre i limiti della macchina (' .. EgtNumToString( BeamData.MAX_LENGTH, 2) .. ') ' EgtOutLog( sOut) EgtOutBox( sOut, 'Lavora Travi', 'WARNING') EgtDraw() From a73c0c85ac7709fbb7be6afdad0ab41eca1b92f6 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 11 Jun 2026 13:05:06 +0200 Subject: [PATCH 4/5] - in PreSimulationLib si usa il grezzo dinamico per i cubetti. Modificate funzioni correlate - in BLADETOWASTE.UpdateDiceRaw alcune correzioni --- LuaLibs/MachiningLib.lua | 10 ++++---- LuaLibs/PreSimulationLib.lua | 48 +++++++++++++++-------------------- StrategyLibs/BLADETOWASTE.lua | 43 +++++++++++++++++-------------- StrategyLibs/FACEBYBLADE.lua | 4 +++ 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index a02e068..19d1465 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -347,7 +347,7 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) return false end -- lavorazione in collisione con il pezzo: non fattibile - local bCollisionFound, bMoveAfterSplit = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters) + local bCollisionFound, bMoveAfterSplit = PreSimulationLib.CheckCollision( CheckCollisionParameters, CheckCollisionOptionalParameters) if bCollisionFound then return false end @@ -373,7 +373,7 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) CheckCollisionOptionalParameters.PointsToCheck = {} table.insert( CheckCollisionOptionalParameters.PointsToCheck, PerpendicularLeadInOut.LeadIn.ptPoint) table.insert( CheckCollisionOptionalParameters.PointsToCheck, PerpendicularLeadInOut.LeadOut.ptPoint) - local bCollisionFoundPerpendicular, bMoveAfterSplitPerpendicular = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters) + local bCollisionFoundPerpendicular, bMoveAfterSplitPerpendicular = PreSimulationLib.CheckCollision( CheckCollisionParameters, CheckCollisionOptionalParameters) -- attacco perpendicolare possibile if not bCollisionFoundPerpendicular then LeadInOut.Perpendicular = PerpendicularLeadInOut @@ -403,7 +403,7 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) CheckCollisionOptionalParameters.PointsToCheck = {} table.insert( CheckCollisionOptionalParameters.PointsToCheck, TangentLeadInOut.LeadIn.ptPoint) table.insert( CheckCollisionOptionalParameters.PointsToCheck, TangentLeadInOut.LeadOut.ptPoint) - local bCollisionFoundTangent, bMoveAfterSplitTangent = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters) + local bCollisionFoundTangent, bMoveAfterSplitTangent = PreSimulationLib.CheckCollision( CheckCollisionParameters, CheckCollisionOptionalParameters) -- attacco tangenziale possibile if not bCollisionFoundTangent then LeadInOut.Tangent = TangentLeadInOut @@ -628,7 +628,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) local bForceLongcutBlade = ToolSearchParameters.bForceLongcutBlade or false local EdgeToMachine = ToolSearchParameters.EdgeToMachine local Part = ToolSearchParameters.Part - local bIsDicing = ToolSearchParameters.bIsDicing or false + local idCheckCollisionTm = ToolSearchParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = ToolSearchParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = ToolSearchParameters.bCannotSplitRestLength or false local bDisableRealElevationCheck = ToolSearchParameters.bDisableRealElevationCheck or false @@ -663,7 +663,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) dDepthToMachine = min( dElevation, TOOLS[i].dMaxDepth) } local BladeEngagementOptionalParameters = { - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength, bDisableRealElevationCheck = bDisableRealElevationCheck diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index ef2d5ba..fb405ef 100644 --- a/LuaLibs/PreSimulationLib.lua +++ b/LuaLibs/PreSimulationLib.lua @@ -305,7 +305,7 @@ local function MoveMachineAxesToPosition( ptOnToolTipCenter, vtHead, vtAux) end ------------------------------------------------------------------------------------------------------------- -local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, bCheckOnlyRestlength) +local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, idCheckCollisionTm) -- spostamento assi macchina in posizione local dDeltaXHeadOffset = MoveMachineAxesToPosition( ptOnToolTipCenter, vtHead, vtAux) @@ -337,32 +337,32 @@ local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Par -- check collisione con pezzo local bCollisionFoundPiece = false - if not bCheckOnlyRestlength then - local idCheckCollisionTm = Part.idBoxTm + if not idCheckCollisionTm then + idCheckCollisionTm = Part.idBoxTm -- se testa o coda attaccate, si considerano nella superficie di collisione if bCannotSplitRestLength then local b3CheckCollision = BeamLib.GetPartBoxWithHeadTail( Part, sRestLengthSideForPreSimulation) idCheckCollisionTm = EgtSurfTmBBox( Part.idTempGroup, b3CheckCollision, false, GDB_RT.GLOB) end - for i = 1, #CollisionSurfTmId do - bCollisionFoundPiece = EgtCDeSolidSolid( idCheckCollisionTm, CollisionSurfTmId[i], BeamData.COLL_SIC) - if not type( bCollisionFoundPiece) == "boolean" then - error( 'Presimulation fail') - end - if EgtGetDebugLevel() >= 3 and bCollisionFoundPiece then - EgtSetColor( CollisionSurfTmId[i], RED()) - end - if bCollisionFoundPiece then - break - end + end + for i = 1, #CollisionSurfTmId do + bCollisionFoundPiece = EgtCDeSolidSolid( idCheckCollisionTm, CollisionSurfTmId[i], BeamData.COLL_SIC) + if not type( bCollisionFoundPiece) == "boolean" then + error( 'Presimulation fail') end + if EgtGetDebugLevel() >= 3 and bCollisionFoundPiece then + EgtSetColor( CollisionSurfTmId[i], RED()) + end + if bCollisionFoundPiece then + break + end + end -- se trovata collisione con pezzo è inutile procedere con il grezzo if bCollisionFoundPiece then return true end - end -- check collisione con grezzo restante, se con il pezzo non c'è collisione e non è un taglio di testa o coda local bCollisionFoundRestLength = false @@ -401,7 +401,7 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam -- parametri opzionali OptionalParameters = OptionalParameters or {} - local bCheckOnlyRestlength = OptionalParameters.bCheckOnlyRestlength or false + local idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false local vtAux = OptionalParameters.vtAux @@ -426,7 +426,7 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam -- se non si trova collisione si ritorna se è necessario separare prima di effettuare la lavorazione (ossia non c'è collisione con il pezzo ma c'è con il grezzo restante) for i = 1, #PointsOnToolTipCenter do - local bCollisionFoundPiece, bCollisionFoundRestLength = CheckCollisionPoint( sAxis, PointsOnToolTipCenter[i], vtHead, vtAux, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, bCheckOnlyRestlength) + local bCollisionFoundPiece, bCollisionFoundRestLength = CheckCollisionPoint( sAxis, PointsOnToolTipCenter[i], vtHead, vtAux, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, idCheckCollisionTm) -- se trovata collisione con pezzo è inutile controllare gli altri punti if bCollisionFoundPiece then @@ -445,7 +445,7 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam end ------------------------------------------------------------------------------------------------------------- -function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, OptionalParameters) +function PreSimulationLib.CheckCollision( Parameters, OptionalParameters) local bCollisionFound local bMoveAfterSplitL3, bMoveAfterSplitR3, bMoveAfterSplitR2, bMoveAfterSplitR1 @@ -459,24 +459,19 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional OptionalParameters = OptionalParameters or {} local OptionalParametersCheckCollisionWithAxis = {} - OptionalParametersCheckCollisionWithAxis.bCheckOnlyRestlength = false OptionalParametersCheckCollisionWithAxis.PointsToCheck = OptionalParameters.PointsToCheck or nil OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' OptionalParametersCheckCollisionWithAxis.bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false OptionalParametersCheckCollisionWithAxis.sBlockedAxis = OptionalParameters.sBlockedAxis OptionalParametersCheckCollisionWithAxis.vtAux = OptionalParameters.vtAux + OptionalParametersCheckCollisionWithAxis.idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sBlockedAxis = OptionalParameters.sBlockedAxis - local bIsDicing = OptionalParameters.bIsDicing or false local bDisableRealElevationCheck = OptionalParameters.bDisableRealElevationCheck or false - local bCheckOnlyRestlengthForAxisABC = false - -- se cubetti in modalità standard (no DownUp) gli assi AB e C si controllano solo con grezzo (ci sarebbe collisione con il materiale già rimosso controllando AB e C con pezzo) - if bIsDicing and ( sBladeEngagement == 'Standard') then - bCheckOnlyRestlengthForAxisABC = true -- se l'elevazione reale (rispetto al pezzo + eventuale materiale in testa/coda) è maggiore del massimo materiale è sempre collisione -- TODO rifare con funzione - elseif not bDisableRealElevationCheck then + if not bDisableRealElevationCheck then local Edge = Parameters.Edge local vtNFace = Parameters.vtNFace local dDepthToMachine = Parameters.dDepthToMachine @@ -523,9 +518,6 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional -- ultimo asse lineare prima dei rotativi (solitamente Z) si controlla sempre bCollisionFound, bMoveAfterSplitL3 = CheckCollisionWithAxis( sL3, Parameters, OptionalParametersCheckCollisionWithAxis) - -- assi rotativi: se richiesto si controlla la collisione solo col grezzo - OptionalParametersCheckCollisionWithAxis.bCheckOnlyRestlength = bCheckOnlyRestlengthForAxisABC - if sR3 and not bCollisionFound then bCollisionFound, bMoveAfterSplitR3 = CheckCollisionWithAxis( sR3, Parameters, OptionalParametersCheckCollisionWithAxis) end diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 9bbb30d..6b43936 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -260,7 +260,7 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) local dShortPartLength = OptionalParameters.dShortPartLength or BeamData.LEN_SHORT_PART local EdgeToMachineTop = OptionalParameters.EdgeToMachineTop local EdgeToMachineBottom = OptionalParameters.EdgeToMachineBottom - local bIsDicing = OptionalParameters.bIsDicing + local idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength -- TODO qui sarebbe meglio avere dExtra come OptionalParameter??? @@ -289,7 +289,7 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) FaceToMachine = Face, EdgeToMachine = EdgeToMachineTop, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -304,7 +304,7 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) FaceToMachine = Face, EdgeToMachine = EdgeToMachineBottom, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -371,7 +371,7 @@ local function GetSingleCutStrategy( Proc, Part, OptionalParameters) local bReduceBladePath = OptionalParameters.bReduceBladePath or false local bAllowFastCuts = OptionalParameters.bAllowFastCuts or false local FaceToMachine = Proc.Faces[OptionalParameters.nFaceToMachineIndex or 1] - local bIsDicing = OptionalParameters.bIsDicing or false + local idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false -- lati da lavorare in base al tipo di lama @@ -390,7 +390,7 @@ local function GetSingleCutStrategy( Proc, Part, OptionalParameters) EdgeToMachineTop = EdgeToMachineList.Top, EdgeToMachineBottom = EdgeToMachineList.Bottom, nToolIndex = nToolIndex, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } @@ -442,7 +442,7 @@ local function GetSingleCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = EdgeToMachineList.TopGuillotine, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -475,7 +475,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) OptionalParameters = OptionalParameters or {} local nToolIndex = OptionalParameters.nToolIndex local FaceToMachine = Proc.Faces[OptionalParameters.nFaceToMachineIndex or 1] - local bIsDicing = OptionalParameters.bIsDicing or false + local idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false @@ -499,7 +499,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = EdgeToMachine, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -512,7 +512,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( FaceToMachine.Edges, -EdgeToMachine.vtN), Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -534,7 +534,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( FaceToMachine.Edges, -EdgeToMachine.vtN), Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -553,7 +553,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = EdgeToMachine, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -589,7 +589,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) FaceToMachine = FaceToMachine, EdgeToMachine = EdgeToMachine, Part = Part, - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength }) @@ -607,7 +607,7 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) dDepthToMachine = dDepthToMachine } local BladeEngagementOptionalParameters = { - bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } @@ -791,11 +791,17 @@ local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, Main -- box del cubetto in riferimento feature local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) - local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) - b3Surf:Add( b3SurfPerpendicular) + if idPerpendicularTm then + local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) + b3Surf:Add( b3SurfPerpendicular) + else + -- se non arriva la superficie perpendicolare è un solo taglio parallelo: si estende il box in Z in modo da uscire dal pezzo + local ptDeltaZ = b3Surf:getMax() + vtZ * ( MainFace.dElevation + 5) + b3Surf:Add( ptDeltaZ) + end -- estensione box per non avere problemi nella sottrazione booleana - if OtherFace then + if OtherFace and idPerpendicularTm then local vtY = vtZ ^ vtX local ptDeltaX = b3Surf:getMax() + vtX * 1 local ptDeltaZ = b3Surf:getMax() + vtZ * 1 @@ -887,7 +893,6 @@ local function CalculateDiceMachinings( vCuts, Parameters) end -- calcolo lavorazione della singola faccia -- per tagli paralleli e faccia aperta si prova a tagliare come se fosse una faccia singola, accorpando i tagli - -- TODO bIsDicing è da mettere a true? local bCanMergeParallelCuts = ( ( i % 2) == 0) and ( Proc.nFct == 1) local bIsDicingOk = true if bCanMergeParallelCuts then @@ -899,7 +904,6 @@ local function CalculateDiceMachinings( vCuts, Parameters) nToolIndex = Tool.nIndex, dExtendAfterTail = dExtendAfterTail, bReduceBladePath = bReduceBladePath, - bIsDicing = false, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } @@ -958,9 +962,10 @@ local function CalculateDiceMachinings( vCuts, Parameters) dRadialStepSpan = 0, dExtendAfterTail = dExtendAfterTail, bIsDicing = true, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength, - bDisableRealElevationCheck = ( i % 2) > 0 -- se taglio perpendicolare non si deve mai considerare il materiale precedente + bDisableRealElevationCheck = true } Cutting = FaceByBlade.Make( ProcTrimesh, Part, FaceToMachine, EdgeToMachine, OptionalParametersFaceByBlade) Cutting.ptCenter = Point3d( ProcTrimesh.Faces[1].ptCenter:getX(), 0, 0) diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 1a6585d..b376796 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -209,6 +209,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local dRadialStepSpan = OptionalParameters.dRadialStepSpan local sUserNotes = OptionalParameters.sUserNotes or '' local bIsDicing = OptionalParameters.bIsDicing or false + local idCheckCollisionTm = OptionalParameters.idCheckCollisionTm local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false local bDisableRealElevationCheck = OptionalParameters.bDisableRealElevationCheck or false @@ -237,6 +238,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar end local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength, bDisableRealElevationCheck = bDisableRealElevationCheck @@ -360,6 +362,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar } local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength, bDisableRealElevationCheck = bDisableRealElevationCheck @@ -478,6 +481,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar } local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, + idCheckCollisionTm = idCheckCollisionTm, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength, bDisableRealElevationCheck = bDisableRealElevationCheck From c506486585909dbf7e026d795cd50a467ba454a2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 11 Jun 2026 13:08:02 +0200 Subject: [PATCH 5/5] - in BLADETOWASTE.UpdateDiceRaw correzione --- StrategyLibs/BLADETOWASTE.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 9bbb30d..55e2ece 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -791,11 +791,17 @@ local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, Main -- box del cubetto in riferimento feature local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) - local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) - b3Surf:Add( b3SurfPerpendicular) + if idPerpendicularTm then + local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) + b3Surf:Add( b3SurfPerpendicular) + else + -- se non arriva la superficie perpendicolare è un solo taglio parallelo: si estende il box in Z in modo da uscire dal pezzo + local ptDeltaZ = b3Surf:getMax() + vtZ * ( MainFace.dElevation + 5) + b3Surf:Add( ptDeltaZ) + end -- estensione box per non avere problemi nella sottrazione booleana - if OtherFace then + if OtherFace and idPerpendicularTm then local vtY = vtZ ^ vtX local ptDeltaX = b3Surf:getMax() + vtX * 1 local ptDeltaZ = b3Surf:getMax() + vtZ * 1