-- Strategia: FACEBYBLADE -- Descrizione -- Strategia di base per la lavorazione delle facce con lama -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FaceData = require( 'FaceData') -- Tabella per definizione modulo local FACEBYBLADE = {} ------------------------------------------------------------------------------------------------------------- local function GetLeadInOutType( Machining) local sLeadInOutType = '' if Machining.bIsStartClosed or Machining.bIsEndClosed or Machining.sCutType == 'Guillotine' or Machining.sCutType == 'Reduced' then sLeadInOutType = 'Perpendicular' else -- testa sopra if TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bTop then if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() > -0.087 or ( abs( Machining.vtToolDirection:getX()) < 0.34202 and abs( Machining.vtToolDirection:getZ()) < 0.7) then sLeadInOutType = 'Perpendicular' else sLeadInOutType = 'Tangent' end elseif abs( Machining.vtEdgeDirection:getZ()) > 0.7 then sLeadInOutType = 'Perpendicular' else -- TODO qui attacco tangenziale speciale tutto da un lato sLeadInOutType = 'Tangent' end -- testa sotto elseif TOOLS[Machining.nToolIndex].SetupInfo.HeadType.bBottom then if abs( Machining.vtToolDirection:getX()) < 0.7 then if Machining.vtToolDirection:getZ() < -GEO.EPS_SMALL or ( abs( Machining.vtToolDirection:getX()) < 0.34202 and abs( Machining.vtToolDirection:getZ()) < 0.7) then sLeadInOutType = 'Perpendicular' else sLeadInOutType = 'Tangent' end elseif abs( Machining.vtEdgeDirection:getZ()) > 0.7 then sLeadInOutType = 'Perpendicular' else -- TODO qui attacco tangenziale speciale tutto da un lato sLeadInOutType = 'Tangent' end -- se testa senza preferenza Top e Bottom si fa sempre attacco tangenziale else sLeadInOutType = 'Tangent' end end return sLeadInOutType end local function CalculateLeadInOut( Machining, EdgeToMachine, bIsSplitFeature) -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) -- accorciamento per lati chiusi (è sempre l'impronta utensile) local dToolMarkLength = sqrt( Machining.dDepthToMachine * TOOLS[Machining.nToolIndex].dDiameter - Machining.dDepthToMachine * Machining.dDepthToMachine) -- allungamento per faccia singola (aperta in tutte le direzioni) local dAddedLengthOpenFace = BeamData.CUT_EXTRA if Machining.sCutType == 'Guillotine' then local dGuillotineLengthToMachine = 1 dAddedLengthOpenFace = ( - EdgeToMachine.dLength + dGuillotineLengthToMachine) / 2 elseif Machining.sCutType == 'Reduced' then dAddedLengthOpenFace = - FACEBYBLADE.GetPathReductionLength( Machining.nToolIndex, Machining.dMaxRadialOffset) end if Machining.bInvert then Machining.bIsStartClosed, Machining.bIsEndClosed = Machining.bIsEndClosed, Machining.bIsStartClosed end local LeadIn = {} local LeadOut = {} Machining.sLeadInOutType = '' LeadIn.dStartAddLength = 0 LeadOut.dEndAddLength = 0 LeadIn.nType = MCH_MILL_LI.LINEAR LeadOut.nType = MCH_MILL_LI.LINEAR LeadIn.dPerpDistance = 0 LeadOut.dPerpDistance = 0 LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 if Machining.bIsStartClosed or Machining.bIsEndClosed or Machining.CloneStepsRadial.nCount > 1 or Machining.Steps.nCount > 1 or bIsSplitFeature then Machining.sLeadInOutType = 'Perpendicular' if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset else LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset LeadOut.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset end else Machining.sLeadInOutType = GetLeadInOutType( Machining) if Machining.sLeadInOutType == 'Perpendicular' then LeadIn.dPerpDistance = 1 LeadOut.dPerpDistance = 1 else -- TODO da rimuovere, già inserito in GetLeadInOutType if abs( Machining.vtEdgeDirection:getZ()) > 0.707 then LeadIn.dPerpDistance = 1 LeadOut.dPerpDistance = 1 else LeadIn.dTangentDistance = TOOLS[Machining.nToolIndex].dDiameter / 2 + BeamData.CUT_SIC LeadOut.dTangentDistance = TOOLS[Machining.nToolIndex].dDiameter / 2 + BeamData.CUT_SIC end end end LeadIn.dElevation = 0 LeadOut.dElevation = 0 LeadIn.dCompLength = 0 LeadOut.dCompLength = 0 if Machining.bIsStartClosed and Machining.bIsEndClosed then LeadIn.dStartAddLength = -dToolMarkLength LeadOut.dEndAddLength = -dToolMarkLength elseif Machining.bIsStartClosed then LeadIn.dStartAddLength = -dToolMarkLength -- eventuale correzione per accorciamento maggiore di larghezza tasca LeadOut.dEndAddLength = max( -LeadIn.dStartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) elseif Machining.bIsEndClosed then LeadOut.dEndAddLength = -dToolMarkLength -- eventuale correzione per accorciamento maggiore di larghezza tasca LeadIn.dStartAddLength = max( -LeadOut.dEndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) else LeadIn.dStartAddLength = dAddedLengthOpenFace LeadOut.dEndAddLength = dAddedLengthOpenFace end -- stima lunghezza reale attacchi per calcolo lunghezza lavorata local dEstimatedLeadInPerpDistance = 0 local dEstimatedLeadInTangentDistance = 0 local dEstimatedLeadOutPerpDistance = 0 local dEstimatedLeadOutTangentDistance = 0 if LeadIn.dPerpDistance > 0 then dEstimatedLeadInPerpDistance = ( Machining.dDepthToMachine + min( TOOLS[Machining.nToolIndex].dSideStep, Machining.dDepthToMachine)) / 2 end if LeadIn.dTangentDistance > 0 then dEstimatedLeadInTangentDistance = TOOLS[Machining.nToolIndex].dDiameter / 2 + BeamData.CUT_SIC end if LeadOut.dPerpDistance > 0 then dEstimatedLeadOutPerpDistance = ( Machining.dDepthToMachine + min( TOOLS[Machining.nToolIndex].dSideStep, Machining.dDepthToMachine)) / 2 end if LeadOut.dTangentDistance > 0 then dEstimatedLeadOutTangentDistance = TOOLS[Machining.nToolIndex].dDiameter / 2 + BeamData.CUT_SIC end LeadIn.dTotalEstimatedDistance = sqrt( dEstimatedLeadInPerpDistance ^ 2 + dEstimatedLeadInTangentDistance ^ 2) + Machining.dStartSafetyLength LeadOut.dTotalEstimatedDistance = sqrt( dEstimatedLeadOutPerpDistance ^ 2 + dEstimatedLeadOutTangentDistance ^ 2) + Machining.dStartSafetyLength return LeadIn, LeadOut end -- TODO implementare SCC in funzione macchina local function GetSCC( vtMachiningDirection, vtEdgeDirection, vtNFace) local nSCC = MCH_SCC.NONE if abs( vtMachiningDirection:getX()) > abs( vtMachiningDirection:getY()) - GEO.EPS_SMALL then -- se il taglio è orizzontale, si gira aggregato lama per facilitare caduta del legno if abs( vtEdgeDirection:getZ()) < 10 * GEO.EPS_SMALL and not AreSameOrOppositeVectorApprox( vtNFace, Z_AX()) then nSCC = EgtIf( ( vtMachiningDirection:getX() > -GEO.EPS_SMALL), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) else nSCC = EgtIf( ( vtMachiningDirection:getX() > -GEO.EPS_SMALL), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) end else -- se il taglio è orizzontale, si gira aggregato lama per facilitare caduta del legno if abs( vtEdgeDirection:getZ()) < 10 * GEO.EPS_SMALL and not AreSameOrOppositeVectorApprox( vtNFace, Z_AX()) then nSCC = EgtIf( ( vtMachiningDirection:getY() > -GEO.EPS_SMALL), MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) else nSCC = EgtIf( ( vtMachiningDirection:getY() > -GEO.EPS_SMALL), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) end end return nSCC end -- dato un certo offset radiale (uscente) e la distanza da mantenere dallo spigolo, calcola di quanto la lama deve arretrare lateralmente rispetto al centro per lavorare il lato function FACEBYBLADE.GetPathReductionLength( nToolIndex, dRadialOffset, OptionalParameters) local Tool = TOOLS[nToolIndex] local dToolRadius = Tool.dDiameter / 2 -- parametri opzionali if not OptionalParameters then OptionalParameters = {} end local dExtra = OptionalParameters.dExtra or BeamData.CUT_EXTRA -- calcolo local dReductionLength = -dExtra if dRadialOffset > dExtra + 10 * GEO.EPS_SMALL then dReductionLength = sqrt( ( dToolRadius - dExtra)^2 - ( dToolRadius - dRadialOffset)^2) end return dReductionLength end -- data la lunghezza del lato da lavorare e la distanza da mantenere dallo spigolo, calcola di quanto la lama deve andare oltre per lavorare il lato function FACEBYBLADE.GetRadialOffsetForGuillotine( nToolIndex, dEdgeLength, OptionalParameters) local Tool = TOOLS[nToolIndex] local dToolRadius = Tool.dDiameter / 2 -- parametri opzionali if not OptionalParameters then OptionalParameters = {} end local dExtra = OptionalParameters.dExtra or BeamData.CUT_EXTRA -- calcolo local dRadialOffset = dToolRadius - sqrt( ( dToolRadius - dExtra)^2 - ( dEdgeLength / 2)^2) if dRadialOffset < dExtra + 10 * GEO.EPS_SMALL then dRadialOffset = GEO.INFINITO end return dRadialOffset end function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) local Cutting = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) Cutting.bIsApplicable = true Cutting.dDepthToMachine = 0 Cutting.sMessage = '' Cutting.idProc = Proc.id Cutting.dResidualDepth = EdgeToMachine.dElevation Cutting.dCompletionPercentage = 0 Cutting.dToolMarkLength = 0 Cutting.sEdgeType = EdgeToMachine.sType Cutting.nFeatureSegment = 1 -- parametri opzionali if not OptionalParameters then OptionalParameters = {} end local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 local dPocketHeight = OptionalParameters.dPocketHeight or 0 local dDepthToMachine = OptionalParameters.dDepthToMachine or EdgeToMachine.dElevation local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false local OppositeToolDirectionMode = OptionalParameters.OppositeToolDirectionMode or 'Disabled' local bReduceBladePath = OptionalParameters.bReduceBladePath or false local sDepth = OptionalParameters.sDepth or 0 local nToolIndex = OptionalParameters.nToolIndex local dLongitudinalOffset = OptionalParameters.dLongitudinalOffset or 0 if OptionalParameters.dPocketHeight then dLongitudinalOffset = 0 end local dRadialStepSpan = OptionalParameters.dRadialStepSpan local dMinNzDownUp = OptionalParameters.dMinNzDownUp local sUserNotes = OptionalParameters.sUserNotes or '' -- lunghezze, direzioni e punti caratteristici della lavorazione e del lato lavorato Cutting.dEdgeLength = EdgeToMachine.dLength if OppositeToolDirectionMode == 'Enabled' then Cutting.vtToolDirection = -EdgeToMachine.vtN else Cutting.vtToolDirection = EdgeToMachine.vtN end Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN -- TODO conviene spostare questi calcoli nel FaceData? Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) -- TODO gestire lama da sotto -- se si conosce il limite downUp (utensile forzato o downUp forzato) si decide se invertire (ToolInvert) -- TODO esiste un limite downUp massimo per la lama da sopra?? if nToolIndex and not dMinNzDownUp then dMinNzDownUp = TOOLS[nToolIndex].SetupInfo.GetMinNzDownUp( Part.b3Raw, FaceToMachine.vtN, Cutting.vtToolDirection, TOOLS[nToolIndex]) end if dMinNzDownUp and FaceToMachine.vtN:getZ() < dMinNzDownUp then Cutting.bToolInvert = true else Cutting.bToolInvert = false end -- ricerca utensile if nToolIndex then Cutting.nToolIndex = nToolIndex else local ToolSearchParameters = {} ToolSearchParameters.dElevation = dDepthToMachine if Cutting.bToolInvert then ToolSearchParameters.vtN = -FaceToMachine.vtN else ToolSearchParameters.vtN = FaceToMachine.vtN end ToolSearchParameters.bAllowTopHead = true -- TODO bisognerà implementare anche la lama da sotto ToolSearchParameters.bAllowBottomHead = false ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) -- ora che l'utensile è scelto, se non era definito l'angolo di DownUp lo verifico per decidere se invertire if ToolInfo.nToolIndex and not dMinNzDownUp then dMinNzDownUp = TOOLS[ToolInfo.nToolIndex].SetupInfo.GetMinNzDownUp( Part.b3Raw, FaceToMachine.vtN, Cutting.vtToolDirection, TOOLS[ToolInfo.nToolIndex]) if FaceToMachine.vtN:getZ() < dMinNzDownUp then Cutting.bToolInvert = true end end Cutting.nToolIndex = ToolInfo.nToolIndex end if not TOOLS[Cutting.nToolIndex] or not TOOLS[Cutting.nToolIndex].sName then Cutting.sMessage = 'Blade not found' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la lavorazione non è applicabile if OptionalParameters.dPocketHeight and ( TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL) then Cutting.sMessage = 'Pocket too narrow for blade thickness' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end -- se tasca chiusa da entrambi i lati e più stretta della lama la lavorazione non è applicabile if not ( EdgeToMachine.bIsStartOpen or EdgeToMachine.bIsEndOpen) then if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Cutting.sMessage = 'Pocket too narrow for blade diameter' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end end -- parametri della lavorazione -- profondità (parametro DEPTH) Cutting.sDepth = sDepth -- inizio e fine aperti o chiusi Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen -- lato di lavoro e inversione per avere taglio concorde if TOOLS[Cutting.nToolIndex].bIsCCW then Cutting.nWorkside = MCH_MILL_WS.RIGHT Cutting.bInvert = true else Cutting.nWorkside = MCH_MILL_WS.LEFT Cutting.bInvert = false end -- se OppositeToolDirectionMode è Optimized, se possibile e necessario, si attiva per garantire taglio concorde e verso l'alto (massima qualità) if ( OppositeToolDirectionMode == 'Optimized') and ( Proc.nFct == 1) and ( FaceData.IsFaceRhomboid( Proc, FaceToMachine.id)) then OppositeToolDirectionMode = 'Disabled' -- la direzione di percorrenza del lato deve essere verso l'alto; bInvert va considerata perchè inverte la direzione di percorrenza. if ( Cutting.bInvert and Cutting.vtEdgeDirection:getZ() > 100 * GEO.EPS_SMALL) or ( ( not Cutting.bInvert) and Cutting.vtEdgeDirection:getZ() < -100 * GEO.EPS_SMALL) then -- si attiva OppositeToolDirection solo se non cambiano le condizioni di taglio downUp local dNewMinNzDownUp = TOOLS[nToolIndex].SetupInfo.GetMinNzDownUp( Part.b3Raw, FaceToMachine.vtN, -Cutting.vtToolDirection, TOOLS[nToolIndex]) if ( FaceToMachine.vtN:getZ() < dMinNzDownUp) == ( FaceToMachine.vtN:getZ() < dNewMinNzDownUp) then OppositeToolDirectionMode = 'Enabled' Cutting.vtToolDirection = -EdgeToMachine.vtN Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) Cutting.bInvert = not Cutting.bInvert -- se le condizioni downUp cambiano, si setta per tagliare verso l'alto else if Cutting.nWorkside == MCH_MILL_WS.RIGHT then Cutting.nWorkside = MCH_MILL_WS.LEFT Cutting.bInvert = false else Cutting.nWorkside = MCH_MILL_WS.RIGHT Cutting.bInvert = true end end end elseif OppositeToolDirectionMode == 'Enabled' then Cutting.bInvert = not Cutting.bInvert end if Cutting.bToolInvert then Cutting.bInvert = not Cutting.bInvert end -- profondità da lavorare e offset radiale 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 OppositeToolDirectionMode == 'Enabled' 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 OppositeToolDirectionMode == 'Enabled' then Cutting.dRadialOffset = -Cutting.dDepthToMachine else Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine end end else Cutting.dDepthToMachine = dDepthToMachine Cutting.dResidualDepth = 0 Cutting.sCutType = 'Standard' if bReduceBladePath and ( Proc.nFct == 1) and FaceData.IsFaceRectangular( Proc, FaceToMachine.id) then local bIsTopBlade = TOOLS[nToolIndex].SetupInfo.HeadType.bTop Cutting.dMaxRadialOffset = TOOLS[nToolIndex].dMaxMaterial - Cutting.dDepthToMachine - BeamData.CUT_SIC Cutting.dRadialOffsetGuillotine = FACEBYBLADE.GetRadialOffsetForGuillotine( nToolIndex, EdgeToMachine.dLength) if Cutting.dMaxRadialOffset > 10 * GEO.EPS_SMALL then -- taglio a ghigliottina if bIsTopBlade and ( Cutting.dRadialOffsetGuillotine < Cutting.dMaxRadialOffset - 10 * GEO.EPS_SMALL) then dDepthToMachine = Cutting.dDepthToMachine + Cutting.dRadialOffsetGuillotine Cutting.sCutType = 'Guillotine' -- taglio ridotto else dDepthToMachine = Cutting.dDepthToMachine + Cutting.dMaxRadialOffset Cutting.sCutType = 'Reduced' end end end if OppositeToolDirectionMode == 'Enabled' then Cutting.dRadialOffset = -dDepthToMachine else Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine end end -- completamento Cutting.dCompletionPercentage = ( 1 - Cutting.dResidualDepth / Cutting.dDepthToMachine) * 100 -- step verticale e offset longitudinale Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Cutting.nToolIndex].dThickness) Cutting.Steps.nStepType = MCH_MILL_ST.ONEWAY Cutting.dMaxElev = Cutting.Steps.dStep * Cutting.Steps.nCount - 10 * GEO.EPS_SMALL if Cutting.bToolInvert then if Cutting.Steps.nCount > 1 then Cutting.dLongitudinalOffset = - dPocketHeight else Cutting.dLongitudinalOffset = - TOOLS[Cutting.nToolIndex].dThickness - dLongitudinalOffset end else Cutting.dLongitudinalOffset = dLongitudinalOffset end -- distanza di sicurezza Cutting.dStartSafetyLength = BeamData.CUT_SIC -- overlap Cutting.dOverlap = 0 -- EdgeUse e frame lavorazione if OppositeToolDirectionMode == 'Enabled' then Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -Cutting.vtToolDirection) --Cutting.vtFaceUse = -Cutting.vtToolDirection Cutting.nEdgesFaceUse = EdgeToMachine.id else Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( Cutting.vtToolDirection) --Cutting.vtFaceUse = Cutting.vtToolDirection Cutting.nEdgesFaceUse = EdgeToMachine.id end -- SCC Cutting.nSCC = GetSCC( Cutting.vtToolDirection, Cutting.vtEdgeDirection, FaceToMachine.vtN) -- asse bloccato Cutting.sBlockedAxis = BeamLib.GetBlockedAxis( Cutting.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN, EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX())) -- eventuale step orizzontale Cutting.CloneStepsRadial = {} if not dRadialStepSpan then dRadialStepSpan = Cutting.dDepthToMachine end if dRadialStepSpan > 10 * GEO.EPS_SMALL and TOOLS[Cutting.nToolIndex].dSideStep then Cutting.CloneStepsRadial = MachiningLib.GetMachiningSteps( dRadialStepSpan, TOOLS[Cutting.nToolIndex].dSideStep) else Cutting.CloneStepsRadial.nCount = 1 Cutting.CloneStepsRadial.dStep = Cutting.dDepthToMachine end -- approccio e retrazione Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine, bIsSplitFeature) -- lunghezza lavorata -- TODO per il calcolo del dLengthOnX si deve correggere con allungamento / accorciamento percorso Cutting.dLengthToMachine = EdgeToMachine.dLength + Cutting.LeadIn.dStartAddLength + Cutting.LeadOut.dEndAddLength local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) Cutting.dLengthOnX = b3BoxEdge:getDimX() Cutting.dTimeToMachine, Cutting.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Cutting, Part) -- lunghezza impronta lama if Cutting.bIsStartClosed and Cutting.bIsEndClosed then Cutting.dToolMarkLength = abs( min( Cutting.LeadIn.dStartAddLength, Cutting.LeadOut.dEndAddLength)) elseif Cutting.bIsStartClosed then Cutting.dToolMarkLength = abs( Cutting.LeadIn.dStartAddLength) elseif Cutting.bIsEndClosed then Cutting.dToolMarkLength = abs( Cutting.LeadOut.dEndAddLength) end -- area lavorata Cutting.dAreaToMachine = min( EdgeToMachine.dElevation, Cutting.dDepthToMachine) * ( min( Cutting.dEdgeLength, Cutting.dLengthToMachine + 2 * Cutting.dToolMarkLength)) -- geometria Cutting.Geometry = {{Cutting.idProc, FaceToMachine.id}} -- note utente Cutting.sUserNotes = sUserNotes -- nome operazione Cutting.sOperationName = 'Cut_' .. ( EgtGetName( Cutting.idProc) or tostring( Cutting.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte local bIsTruncatingCutOnTail = Proc.Topology and ( Proc.Topology.sName == 'Cut-1-Through' or Proc.Topology.sName == 'TailCut') and Proc.AffectedFaces.bLeft if bIsTruncatingCutOnTail then Cutting.sStage = 'AfterTail' elseif Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Cutting.vtToolDirection:getX() < 0.707)) then local dLengthOnX = Cutting.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione if bIsSplitFeature then dLengthOnX = 0 end local bStartLeft = MachiningLib.StartsLeftSide( Cutting) local dAddLengthLeftSide = Cutting.LeadOut.dEndAddLength local dAddLengthToReduce = sqrt( Cutting.dDepthToMachine * TOOLS[Cutting.nToolIndex].dDiameter - Cutting.dDepthToMachine * Cutting.dDepthToMachine) if bStartLeft then dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength end if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' else Cutting.bIsApplicable = false end elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' else if bStartLeft then Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail else Cutting.LeadOut.dEndAddLength = - dAddLengthToReduce + dExtendAfterTail end end end end return Cutting end ------------------------------------------------------------------------------------------------------------- return FACEBYBLADE