-- Strategia: FACEBYBLADE -- Descrizione -- Strategia di base per la lavorazione delle facce con lama -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamDataNew') local MachiningLib = require( 'MachiningLib') local FaceData = require( 'FaceData') local LeadInOutLib = require( 'LeadInOutLib') -- Tabella per definizione modulo local FACEBYBLADE = {} ------------------------------------------------------------------------------------------------------------- -- i parametri si leggono da LeadInOut (engagement) e si modificano solo se necessario local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature) local LeadIn local LeadOut -- in certe condizioni si deve forzare attacco perpendicolare if Machining.bIsStartClosed or Machining.bIsEndClosed or Machining.CloneStepsRadial.nCount > 1 or Machining.Steps.nCount > 1 or bIsSplitFeature then if Machining.LeadInOut.Perpendicular then Machining.sLeadInOutType = 'Perpendicular' -- se attacco perpendicolare richiesto ma non disponibile, la lavorazione non è fattibile else return end else Machining.sLeadInOutType = Machining.LeadInOut.sChosen end -- si prendono i valori che arrivano da LeadInOut (engagement) LeadIn = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.sLeadInOutType].LeadIn) LeadOut = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.sLeadInOutType].LeadOut) -- se senso di percorrenza invertito si invertono anche gli attacchi if Machining.bInvert then Machining.bIsStartClosed, Machining.bIsEndClosed = Machining.bIsEndClosed, Machining.bIsStartClosed LeadIn, LeadOut = LeadInOutLib.InvertLeadInOut( LeadIn, LeadOut) end -- in caso di percorso ridotto gli attacchi vanno adeguati if Machining.sEdgeUsage == 'Guillotine' then local dGuillotineLengthToMachine = 1 LeadIn.dStartAddLength = ( - EdgeToMachine.dLength + dGuillotineLengthToMachine) / 2 LeadOut.dEndAddLength = ( - EdgeToMachine.dLength + dGuillotineLengthToMachine) / 2 LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset LeadIn.dTangentDistance = 0 LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset LeadOut.dTangentDistance = 0 LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2) LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2) elseif Machining.sEdgeUsage == 'Reduced' then LeadIn.dStartAddLength = - FACEBYBLADE.GetPathReductionLength( Machining.nToolIndex, Machining.dMaxRadialOffset) LeadOut.dEndAddLength = - FACEBYBLADE.GetPathReductionLength( Machining.nToolIndex, Machining.dMaxRadialOffset) LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset LeadIn.dTangentDistance = 0 LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset LeadOut.dTangentDistance = 0 LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2) LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2) end -- se accorciamenti maggiori della lunghezza lato, la lavorazione non è fattibile if LeadIn.dStartAddLength + LeadOut.dEndAddLength + EdgeToMachine.dLength < 1 then return end -- se lavorazione con OppositeToolDirection o ridotta l'attacco va corretto if not AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset LeadOut.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 end -- stima lunghezza reale attacchi per calcolo lunghezza lavorata -- TODO sistemare per nuovi attacchi 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 da eliminare, sostituita da funzione macchina function FACEBYBLADE.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 sUserNotes = OptionalParameters.sUserNotes or '' local bIsDicing = OptionalParameters.bIsDicing or false local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false -- lunghezze, direzioni e punti caratteristici della lavorazione e del lato lavorato Cutting.dEdgeLength = EdgeToMachine.dLength -- TODO questa deve essere ptEnd - ptStart Cutting.vtEdgeDirection = Vector3d( EdgeToMachine.vtEdge) Cutting.vtToolDirection = EdgeToMachine.vtN Cutting.ptEdge1, Cutting.ptEdge2 = EdgeToMachine.ptStart, EdgeToMachine.ptEnd local EdgeToMachineOpposite = BeamLib.FindEdgeBestOrientedAsDirection( FaceToMachine.Edges, -EdgeToMachine.vtN) -- l'utensile arriva da fuori: si determina se il taglio è fattibile e il modo di lavorare della lama if nToolIndex then Cutting.nToolIndex = nToolIndex local BladeEngagementParameters = { Face = FaceToMachine, Edge = EdgeToMachine, Part = Part, Tool = TOOLS[Cutting.nToolIndex], dDepthToMachine = dDepthToMachine } local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } local Engagement TIMER:startElapsed( 'GetBladeEngagement') Cutting.bIsApplicable, Engagement = MachiningLib.GetBladeEngagement( BladeEngagementParameters, BladeEngagementOptionalParameters) TIMER:stopElapsed( 'GetBladeEngagement') if Cutting.bIsApplicable then Cutting.sBladeEngagement = Engagement.sBladeEngagement Cutting.bMoveAfterSplit = Engagement.bMoveAfterSplit Cutting.LeadInOut = Engagement.LeadInOut end -- utensile da cercare: si prende la lama migliore che può effettuare questo taglio, senza particolari analisi else local ToolSearchParameters = {} ToolSearchParameters.dElevation = dDepthToMachine ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade ToolSearchParameters.FaceToMachine = FaceToMachine ToolSearchParameters.EdgeToMachine = EdgeToMachine ToolSearchParameters.Part = Part ToolSearchParameters.sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation ToolSearchParameters.bCannotSplitRestLength = bCannotSplitRestLength local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) Cutting.nToolIndex = ToolInfo.nToolIndex if Cutting.nToolIndex then Cutting.sBladeEngagement = ToolInfo.Engagement.sBladeEngagement Cutting.bMoveAfterSplit = ToolInfo.Engagement.bMoveAfterSplit Cutting.LeadInOut = ToolInfo.Engagement.LeadInOut end -- se non trovato utensile, la lavorazione non è applicabile if not Cutting.nToolIndex then Cutting.bIsApplicable = false end end -- orientamento non raggiungibile o lama non trovata: non applicabile if not Cutting.bIsApplicable 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 -- TODO vedere se la rimozione di questo crea problemi -- 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 -- si settano lato di lavoro e inversione per avere concordanza 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 -- ToolInvert if Cutting.sBladeEngagement == 'DownUp' then Cutting.bToolInvert = true Cutting.bInvert = not Cutting.bInvert end -- se dicing, lato di lavoro e inversione per avere taglio sempre verso l'alto if bIsDicing and ( Cutting.bInvert and Cutting.vtEdgeDirection:getZ() > 100 * GEO.EPS_SMALL) or ( ( not Cutting.bInvert) and Cutting.vtEdgeDirection:getZ() < -100 * GEO.EPS_SMALL) then Cutting.bInvert = not Cutting.bInvert if Cutting.nWorkside == MCH_MILL_WS.LEFT then Cutting.nWorkside = MCH_MILL_WS.RIGHT else Cutting.nWorkside = MCH_MILL_WS.LEFT end end -- analisi fattibilità lavorazione dal lato opposto if OppositeToolDirectionMode ~= 'Disabled' then -- lavorando dalla direzione opposta si verifica come se si lavorasse il lato opposto local BladeEngagementParameters = { Face = FaceToMachine, Edge = EdgeToMachineOpposite, Part = Part, Tool = TOOLS[Cutting.nToolIndex], dDepthToMachine = dDepthToMachine } local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } TIMER:startElapsed( 'GetBladeEngagement') local bIsApplicableOpposite, EngagementOpposite = MachiningLib.GetBladeEngagement( BladeEngagementParameters, BladeEngagementOptionalParameters) TIMER:stopElapsed( 'GetBladeEngagement') -- taglio opposto non fattibile if not bIsApplicableOpposite then -- se richiesto, si ritorna non applicabile if OppositeToolDirectionMode == 'Enabled' then Cutting.sMessage = 'Orientation not reachable' Cutting.bIsApplicable = false return Cutting, EdgeToMachine.dElevation -- se opzionale, si disabilita elseif OppositeToolDirectionMode == 'Optimized' then OppositeToolDirectionMode = 'Disabled' end end -- se OppositeToolDirectionMode è Optimized, se possibile e necessario, si attiva la lavorazione dal lato opposto per garantire taglio concorde e verso l'alto (massima qualità) if ( OppositeToolDirectionMode == 'Optimized') and ( Proc.nFct == 1) and ( FaceData.IsFaceRectangle( FaceToMachine)) then OppositeToolDirectionMode = 'Disabled' -- la direzione di percorrenza del lato deve essere verso l'alto; bInvert va considerata perchè inverte la direzione di percorrenza -- il BladeEngagement non deve cambiare, altrimenti è inutile invertire la direzione if ( EngagementOpposite.sBladeEngagement == Cutting.sBladeEngagement) and ( EngagementOpposite.bMoveAfterSplit == Cutting.bMoveAfterSplit) and ( Cutting.bInvert and Cutting.vtEdgeDirection:getZ() > 100 * GEO.EPS_SMALL) or ( ( not Cutting.bInvert) and Cutting.vtEdgeDirection:getZ() < -100 * GEO.EPS_SMALL) then OppositeToolDirectionMode = 'Enabled' end end if OppositeToolDirectionMode == 'Enabled' then Cutting.vtToolDirection = EdgeToMachineOpposite.vtN Cutting.ptEdge1, Cutting.ptEdge2 = EdgeToMachineOpposite.ptStart, EdgeToMachineOpposite.ptEnd Cutting.bInvert = not Cutting.bInvert -- TODO da migliorare!!!!!!!!! if not EngagementOpposite.LeadInOut.Perpendicular then Cutting.LeadInOut.Perpendicular = nil end if not EngagementOpposite.LeadInOut.Tangent then Cutting.LeadInOut.Tangent = nil end end end -- TODO implementare lavorazione in DownUp se non è già DownUp e non si è riusciti a mantenere verso l'alto e concorde (testare solo DownUp)) -- 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.sEdgeUsage = 'Standard' if bReduceBladePath and ( Proc.nFct == 1) and FaceData.IsFaceRectangle( FaceToMachine) then -- TODO la lama sotto deve poter ridurre. Ghigliottina sì o no? local bIsTopBlade = TOOLS[Cutting.nToolIndex].SetupInfo.HeadType.bTop Cutting.dMaxRadialOffset = TOOLS[Cutting.nToolIndex].dMaxMaterial - Cutting.dDepthToMachine - BeamData.CUT_SIC Cutting.dRadialOffsetGuillotine = FACEBYBLADE.GetRadialOffsetForGuillotine( Cutting.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.sEdgeUsage = 'Guillotine' -- taglio ridotto else dDepthToMachine = Cutting.dDepthToMachine + Cutting.dMaxRadialOffset Cutting.sEdgeUsage = 'Reduced' end end end -- se cambiata la profondità dDepthToMachine, si ritesta la fattibilità del taglio if Cutting.sEdgeUsage ~= 'Standard' then local EdgeToMachineForEngagement = EdgeToMachine if OppositeToolDirectionMode == 'Enabled' then EdgeToMachineForEngagement = EdgeToMachineOpposite end local BladeEngagementParameters = { Face = FaceToMachine, Edge = EdgeToMachineForEngagement, Part = Part, Tool = TOOLS[Cutting.nToolIndex], dDepthToMachine = dDepthToMachine } local BladeEngagementOptionalParameters = { bIsDicing = bIsDicing, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } TIMER:startElapsed( 'GetBladeEngagement') local bIsApplicable, CurrentEngagement = MachiningLib.GetBladeEngagement( BladeEngagementParameters, BladeEngagementOptionalParameters ) TIMER:stopElapsed( 'GetBladeEngagement') -- se non fattibile o cambiano le condizioni BladeEngagement, non si riduce if not ( bIsApplicable and ( CurrentEngagement.sBladeEngagement == Cutting.sBladeEngagement) and ( CurrentEngagement.bMoveAfterSplit == Cutting.bMoveAfterSplit)) then Cutting.sEdgeUsage = 'Standard' dDepthToMachine = Cutting.dDepthToMachine end end -- offset radiale (cambia se taglio opposto) 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( true, 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 = TOOLS[Cutting.nToolIndex].SetupInfo.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( true, dRadialStepSpan, TOOLS[Cutting.nToolIndex].dSideStep) else Cutting.CloneStepsRadial.nCount = 1 Cutting.CloneStepsRadial.dStep = Cutting.dDepthToMachine end -- approccio e retrazione Cutting.LeadIn, Cutting.LeadOut = GetLeadInOut( Cutting, EdgeToMachine, bIsSplitFeature) -- se il calcolo attacchi fallisce, la lavorazione non è fattibile if not Cutting.LeadIn or not Cutting.LeadOut then Cutting.bIsApplicable = false return Cutting end -- solo per debug --Cutting.nOutRaw = 3 -- 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 -- TODO rimpiazzare con LeadInOut.dToolMarkLength 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 Cutting.bMoveAfterSplit = Cutting.bMoveAfterSplit or Cutting.LeadIn.bMoveAfterSplit or Cutting.LeadOut.bMoveAfterSplit local bIsTruncatingCutOnTail = Proc.Topology and ( Proc.Topology.sName == 'Cut-1-Through' or Proc.Topology.sName == 'TailCut') and Proc.AffectedFaces.bLeft if Cutting.bMoveAfterSplit or 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' Cutting.bMoveAfterSplit = true else Cutting.bIsApplicable = false end elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' Cutting.bMoveAfterSplit = true else if bStartLeft then Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail else Cutting.LeadOut.dEndAddLength = - dAddLengthToReduce + dExtendAfterTail end end end end return Cutting end ------------------------------------------------------------------------------------------------------------- return FACEBYBLADE