From edd00a7b8f084df03f58a33f67d5792161f8bca5 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 25 Mar 2025 18:59:29 +0100 Subject: [PATCH] - in MachiningLib.AddMachinings gestito attacco non perpendicolare - in BLADEKEEPWASTE sistemato sorting lavorazioni - in FACEBYBLADE e FACEBYMILL correzioni per lavorazione facce non chiuse sopra --- LuaLibs/MachiningLib.lua | 10 +++-- StrategyLibs/BLADEKEEPWASTE.lua | 72 ++++++++++++++++++--------------- StrategyLibs/FACEBYBLADE.lua | 37 ++++++++++------- StrategyLibs/FACEBYMILL.lua | 32 ++++++++++----- 4 files changed, 90 insertions(+), 61 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 2c1cc5c..2147aaa 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -542,12 +542,14 @@ function MachiningLib.AddMachinings( Proc, Machining, AuxiliaryData) local dOriginalLeadOutPerpDistance = Machining.LeadOut.dPerpDistance for i = 1, Machining.CloneStepsHorizontal.nCount do AuxiliaryData.Clones[i] = {} - AuxiliaryData.Clones[i].LeadIn = {} - AuxiliaryData.Clones[i].LeadOut = {} AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffset + Machining.CloneStepsHorizontal.dStep * ( Machining.CloneStepsHorizontal.nCount - i) -- update distanza perpendicolare attacco per contemplare l'offset applicato - AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset - AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset + if abs( dOriginalLeadInPerpDistance) > 10 * GEO.EPS_SMALL and abs( dOriginalLeadOutPerpDistance) > 10 * GEO.EPS_SMALL then + AuxiliaryData.Clones[i].LeadIn = {} + AuxiliaryData.Clones[i].LeadOut = {} + AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset + AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset + end end elseif Machining.CloneStepsVertical and Machining.CloneStepsVertical.nCount > 1 then if not AuxiliaryData then diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 81d7c97..1b9cefa 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -16,7 +16,7 @@ local FaceByBlade = require('FACEBYBLADE') local FaceByMill = require('FACEBYMILL') -- tabella per definizione modulo - +local Machinings = {} ------------------------------------------------------------------------------------------------------------- local function CompareEdges( EdgeA, EdgeB) -- prima i lati orientati lungo X @@ -57,23 +57,30 @@ local function SortMachiningsBySegment( MachiningA, MachiningB) return false elseif MachiningB.nFeatureSegment > MachiningA.nFeatureSegment then return true - -- se segmento uguale, si minimizzano i cambi di lato + -- se segmento uguale, si guarda la priorità else - local bIsOddSegment = ( MachiningA.nFeatureSegment % 2 ~= 0) - if MachiningA.vtToolDirection:getY() < MachiningB.vtToolDirection:getY() - 10 * GEO.EPS_SMALL then - if bIsOddSegment then - return true - else - return false - end - elseif MachiningA.vtToolDirection:getY() > MachiningB.vtToolDirection:getY() + 10 * GEO.EPS_SMALL then - if bIsOddSegment then - return false - else - return true - end - else + if MachiningA.nInternalSortingPriority > MachiningB.nInternalSortingPriority then return false + elseif MachiningB.nInternalSortingPriority > MachiningA.nInternalSortingPriority then + return true + -- se priorità uguale, si minimizzano i cambi di lato + else + local bIsOddSegment = ( MachiningA.nFeatureSegment % 2 ~= 0) + if MachiningA.vtToolDirection:getY() < MachiningB.vtToolDirection:getY() - 10 * GEO.EPS_SMALL then + if bIsOddSegment then + return true + else + return false + end + elseif MachiningA.vtToolDirection:getY() > MachiningB.vtToolDirection:getY() + 10 * GEO.EPS_SMALL then + if bIsOddSegment then + return false + else + return true + end + else + return false + end end end end @@ -85,8 +92,8 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) local Result = {} - local Machining = {} - Machining.Result = {} + Machinings = {} + local CreatedMachinings = {} local Cutting1 = {} local Cutting2 = {} @@ -157,36 +164,37 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- calcolo lavorazioni -- taglio eventuali facce di chiusura for i = 1, #LongFaces do - local CuttingLongFace = {} + local Cutting = {} local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} - CuttingLongFace = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[i], Proc.MainFaces.LongFaces[i].MainEdges.BottomEdge, OptionalParametersFaceByBlade) - table.insert( Machining.Result, CuttingLongFace) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[i], Proc.MainFaces.LongFaces[i].MainEdges.BottomEdge, OptionalParametersFaceByBlade) + Cutting.nInternalSortingPriority = 1 + table.insert( CreatedMachinings, Cutting) end -- faccia di fondo -- primo lato local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade) - table.insert( Machining.Result, Cutting1) + Cutting1.nInternalSortingPriority = 3 + table.insert( CreatedMachinings, Cutting1) -- secondo lato OptionalParametersFaceByBlade.bOppositeToolDirection = true Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade) - table.insert( Machining.Result, Cutting2) + Cutting2.nInternalSortingPriority = 3 + table.insert( CreatedMachinings, Cutting2) -- eventuale pulitura raggio lama if bFinishWithMill then for i = 1, #LongFaces do - local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, - dDepthToMachine = max( Cutting1.dBladeMarkLength, Cutting2.dBladeMarkLength) - } - local MillingClosedSide = FaceByMill.Make( Proc, Part, BottomFace, BottomFace.MainEdges.LongEdges[i], OptionalParametersFaceByMill) - table.insert( Machining.Result, MillingClosedSide) + local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} + local Milling = FaceByMill.Make( Proc, Part, BottomFace, BottomFace.MainEdges.LongEdges[i], OptionalParametersFaceByMill) + Milling.nInternalSortingPriority = 2 + table.insert( CreatedMachinings, Milling) end end -- lavorazioni raggruppate in unica lista - local Machinings = {} - for i = 1, #Machining.Result do - if Machining.Result[i].bIsApplicable then - table.insert( Machinings, Machining.Result[i]) + for i = 1, #CreatedMachinings do + if CreatedMachinings[i].bIsApplicable then + table.insert( Machinings, CreatedMachinings[i]) end end diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index c4a2cda..a5a5228 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -19,7 +19,7 @@ local function GetLeadInOutType( Machining) else -- testa sopra if TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bTop then - if Machining.vtToolDirection:getX() < 0.7 then + if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() > -0.087 or abs( Machining.vtToolDirection:getX()) < 0.34202 then sLeadInOutType = 'Perpendicular' @@ -34,7 +34,7 @@ local function GetLeadInOutType( Machining) end -- testa sotto elseif TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bBottom then - if Machining.vtToolDirection:getX() < 0.7 then + if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() < -GEO.EPS_SMALL or abs( Machining.vtToolDirection:getX()) < 0.34202 then sLeadInOutType = 'Perpendicular' @@ -78,10 +78,9 @@ local function CalculateLeadInOut( Machining, EdgeToMachine, Part) LeadOut.dPerpDistance = 0 LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - -- TODO da rimuovere controllo numero step quando si sistema la funzione che crea i cloni if Machining.bIsStartClosed or Machining.bIsEndClosed - or Machining.CloneStepsHorizontal.nCount > 1 then + or Machining.Steps.nCount > 1 then Machining.sLeadInOutType = 'Perpendicular' if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then @@ -279,8 +278,26 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.bInvert = not Cutting.bInvert end -- profondità da lavorare e offset radiale - if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then - -- TODO la depth dovrebbe essere quella del machining + if OptionalParameters.dPocketHeight then + if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then + -- TODO la depth dovrebbe essere quella del machining + Cutting.dDepthToMachine = dDepthToMachine + Cutting.dResidualDepth = 0 + if bOppositeToolDirection then + Cutting.dRadialOffset = -dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine + end + else + Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 + Cutting.dResidualDepth = dDepthToMachine - Cutting.dDepthToMachine + if bOppositeToolDirection then + Cutting.dRadialOffset = -Cutting.dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine + end + end + else Cutting.dDepthToMachine = dDepthToMachine Cutting.dResidualDepth = 0 if bOppositeToolDirection then @@ -288,14 +305,6 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar else Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine end - else - Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 - Cutting.dResidualDepth = dDepthToMachine - Cutting.dDepthToMachine - if bOppositeToolDirection then - Cutting.dRadialOffset = -Cutting.dDepthToMachine - else - Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine - end end -- completamento Cutting.dCompletionPercentage = 100 - Cutting.dResidualDepth / Cutting.dDepthToMachine diff --git a/StrategyLibs/FACEBYMILL.lua b/StrategyLibs/FACEBYMILL.lua index 32c1129..5d30f3b 100644 --- a/StrategyLibs/FACEBYMILL.lua +++ b/StrategyLibs/FACEBYMILL.lua @@ -19,7 +19,7 @@ local function GetLeadInOutType( Machining) else -- testa sopra if TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bTop then - if Machining.vtToolDirection:getX() < 0.7 then + if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() > -0.087 or abs( Machining.vtToolDirection:getX()) < 0.34202 then sLeadInOutType = 'Perpendicular' @@ -34,7 +34,7 @@ local function GetLeadInOutType( Machining) end -- testa sotto elseif TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bBottom then - if Machining.vtToolDirection:getX() < 0.7 then + if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() < -GEO.EPS_SMALL or abs( Machining.vtToolDirection:getX()) < 0.34202 then sLeadInOutType = 'Perpendicular' @@ -78,10 +78,9 @@ local function CalculateLeadInOut( Machining, EdgeToMachine, Part) LeadOut.dPerpDistance = 0 LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - -- TODO da rimuovere controllo numero step quando si sistema la funzione che crea i cloni if Machining.bIsStartClosed or Machining.bIsEndClosed - or Machining.CloneStepsHorizontal.nCount > 1 then + or Machining.Steps.nCount > 1 then Machining.sLeadInOutType = 'Perpendicular' if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then @@ -212,7 +211,7 @@ function FACEBYMILL.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPara else ToolSearchParameters.sMillShape = 'STANDARD' end - ToolSearchParameters.dElevation = dDepthToMachine + ToolSearchParameters.dElevation = FaceToMachine.dElevation -- TODO qui ToolSearchParameters.vtToolDirection andrà sosituito con vtN!! if Milling.bToolInvert then ToolSearchParameters.vtToolDirection = -FaceToMachine.vtN @@ -298,23 +297,34 @@ function FACEBYMILL.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPara Milling.dRadialOffset = EdgeToMachine.dElevation - Milling.dDepthToMachine end end - -- TODO qui bisogna controllare la profondità di lavoro else Milling.dDepthToMachine = dDepthToMachine Milling.dResidualDepth = 0 - Milling.dRadialOffset = 0 + if bOppositeToolDirection then + Milling.dRadialOffset = -dDepthToMachine + else + Milling.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine + end end -- completamento Milling.dCompletionPercentage = 100 - Milling.dResidualDepth / Milling.dDepthToMachine -- step verticale e offset longitudinale - Milling.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Milling.nToolIndex].dThickness) - Milling.Steps.nStepType = MCH_MILL_ST.ONEWAY - Milling.dMaxElev = Milling.Steps.dStep * Milling.Steps.nCount - 10 * GEO.EPS_SMALL + if OptionalParameters.dPocketHeight then + Milling.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Milling.nToolIndex].dMaxMaterial) + Milling.Steps.nStepType = MCH_MILL_ST.ONEWAY + Milling.dMaxElev = Milling.Steps.dStep * Milling.Steps.nCount - 10 * GEO.EPS_SMALL + else + Milling.Steps = {} + Milling.Steps.nCount = 1 + Milling.Steps.dStep = TOOLS[Milling.nToolIndex].dStep + Milling.Steps.nStepType = MCH_MILL_ST.ZIGZAG + Milling.dMaxElev = FaceToMachine.dElevation + end if Milling.bToolInvert then if Milling.Steps.nCount > 1 then Milling.dLongitudinalOffset = - dPocketHeight else - Milling.dLongitudinalOffset = - TOOLS[Milling.nToolIndex].dThickness - dLongitudinalOffset + Milling.dLongitudinalOffset = - TOOLS[Milling.nToolIndex].dMaxMaterial - dLongitudinalOffset end else Milling.dLongitudinalOffset = dLongitudinalOffset