-- Strategia: STR0009 -- Descrizione -- Fresatura di contorno -- Feature tipo Arco -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local BladeToWaste = require('BLADETOWASTE') -- Tabella per definizione modulo local STR0009 = {} local Strategy = {} ------------------------------------------------------------------------------------------------------------- -- TODO gestire il caso in cui non si trova l'utensile local function GetArcStrategy( Proc, Part) local Machining = {} local ToolSearchParameters = {} -- recupero e verifico l'entità curva local idAux = EgtGetInfo( Proc.id, 'AUXID', 'i') if idAux then idAux = idAux + Proc.id end if not idAux or ( EgtGetType( idAux) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr end Proc.idAddAuxGeom = idAux -- recupero i dati della curva e del profilo local dDepth = abs( EgtCurveThickness( idAux)) local vtExtr = EgtCurveExtrusion( idAux, GDB_RT.GLOB) local bToolInvert = ( vtExtr:getZ() < -0.1) local bIsHorizontal = abs( vtExtr:getZ()) < 10 * GEO.EPS_SMALL local bIsFeatureDown = Proc.AffectedFaces.bBottom and not Proc.AffectedFaces.bTop local bIsFeatureBack = Proc.AffectedFaces.bBack and not Proc.AffectedFaces.bFront local bForceStrip = Strategy.Parameters.bForceStrip local dDimStrip = EgtIf( Strategy.Parameters.dStripWidth < 100 * GEO.EPS_SMALL, nil, Strategy.Parameters.dStripWidth) local bExecStrip = false -- se la lavorazione si trova nella parte inferiore o in battuta dietro, il codolo va sempre lasciato if bIsFeatureDown or bIsFeatureBack or bForceStrip then if bIsFeatureDown or bIsFeatureBack then dDimStrip = dDimStrip or max( BeamData.DIM_STRIP or 5, 5) else dDimStrip = dDimStrip or max( BeamData.DIM_STRIP_SMALL or 5, 1) end bExecStrip = true end if not bExecStrip then dDimStrip = 0 end -- se lavorazione orizzontale if bIsHorizontal then local bDouble local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) Milling.bIsApplicable = false ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = EgtIf( bExecStrip, ( dDepth - dDimStrip) / 2, dDepth + BeamData.MILL_OVERLAP) ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) Milling.ToolInfo = {} Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) -- se posso lavorare in una passata, ma utensile trovato non completa la lavorazione, -- allora provo a cercare utensile con massimo materiale sufficiente per fare le due passate, magari trova un utensile più prestante if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then bDouble = true ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2 ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) end Milling.bToolInvert = bToolInvert Milling.vtToolDirection = vtExtr if bDouble or bExecStrip then if bDouble then Milling.sDepth = ( dDepth + BeamData.MILL_OVERLAP) / 2 else Milling.sDepth = ( dDepth - dDimStrip) / 2 end table.insert( Machining, Milling) local Milling2 = BeamLib.TableCopyDeep( Milling) table.insert( Machining, Milling2) else Milling.sDepth = dDepth + BeamData.MILL_OVERLAP table.insert( Machining, Milling) end -- se lavorazione verticale else -- si cerca utensile 1 local Milling = {} Milling.bIsApplicable = false ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) Milling.ToolInfo = {} Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) -- si cerca utensile 2 local Milling2 = {} Milling2.bIsApplicable = false ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) Milling2.ToolInfo = {} Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) -- se serve codolo if bExecStrip then -- se a disposizione entrambi gli utensili if Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then table.insert( Machining, Milling) table.insert( Machining, Milling2) -- se disponibile solo primo utensile elseif Milling.ToolInfo.nToolIndex then table.insert( Machining, Milling) -- se disponibile solo secondo utensile elseif Milling2.ToolInfo.nToolIndex then table.insert( Machining, Milling2) -- nessun utensile disponibile else -- non si fa nulla end -- altrimenti senza codolo else -- se utensile 1 esegue completamente if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then table.insert( Machining, Milling) -- se utensile 2 esegue completamente elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then table.insert( Machining, Milling2) -- se possono lavorare entrambi elseif Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then table.insert( Machining, Milling) table.insert( Machining, Milling2) -- se utensile 1 non completo elseif Milling.ToolInfo.nToolIndex then table.insert( Machining, Milling) -- se utensile 2 non completo elseif Milling2.ToolInfo.nToolIndex then table.insert( Machining, Milling2) end end end -- TODO VOTO DA FARE!!!! Strategy.Result.sStatus = 'Completed' Strategy.Result.nCompletionIndex = 5 Strategy.Result.dMRR = MachiningLib.GetToolMRR( Machining[1].ToolInfo or Machining[2].ToolInfo) Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') Strategy.Result.sInfo = '' return Machining end ------------------------------------------------------------------------------------------------------------- function STR0009.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) Strategy.Machinings = {} Strategy.Result = {} local bAreAllMachiningsAdded = true local Milling = {} Strategy.Machinings = GetArcStrategy( Proc, Part) if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) for i = 1, #Strategy.Machinings do Strategy.Machinings[i].Geometry = {{ Proc.idAddAuxGeom, -1}} Strategy.Machinings[i].nToolIndex = Strategy.Machinings[i].ToolInfo.nToolIndex Strategy.Machinings[i].nType = MCH_MY.MILLING Strategy.Machinings[i].dStartSafetyLength = 0 Strategy.Machinings[i].Steps = {} Strategy.Machinings[i].Steps.dStep = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dStep Strategy.Machinings[i].Steps = MachiningLib.GetMachiningSteps( tonumber( Strategy.Machinings[i].sDepth), TOOLS[Strategy.Machinings[i].nToolIndex].dStep) -- LeadIn / LeadOut Strategy.Machinings[i].LeadIn = {} Strategy.Machinings[i].LeadOut = {} Strategy.Machinings[i].LeadIn.nType = MCH_MILL_LI.TANGENT Strategy.Machinings[i].LeadOut.nType = MCH_MILL_LI.TANGENT Strategy.Machinings[i].LeadIn.dTangentDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC Strategy.Machinings[i].LeadIn.dPerpDistance = 0 Strategy.Machinings[i].LeadIn.dStartAddLength = 0 Strategy.Machinings[i].LeadOut.dTangentDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC Strategy.Machinings[i].LeadOut.dPerpDistance = 0 Strategy.Machinings[i].LeadOut.dEndAddLength = 0 if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then Strategy.Machinings[i].sStage = 'AfterTail' end -- preparo attacco/uscita in caso di spezzatura arco Strategy.Machinings[i].LeadInForSplit = BeamLib.TableCopyDeep( Strategy.Machinings[i].LeadIn) Strategy.Machinings[i].LeadOutForSplit = BeamLib.TableCopyDeep( Strategy.Machinings[i].LeadOut) Strategy.Machinings[i].LeadInForSplit.nType = MCH_MILL_LI.LINEAR Strategy.Machinings[i].LeadOutForSplit.nType = MCH_MILL_LI.LINEAR Strategy.Machinings[i].LeadInForSplit.dTangentDistance = 0 Strategy.Machinings[i].LeadInForSplit.dPerpDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC Strategy.Machinings[i].LeadOutForSplit.dTangentDistance = 0 Strategy.Machinings[i].LeadOutForSplit.dPerpDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC -- sistemo il lato e la direzione di lavoro if i == 1 then Strategy.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, false, true) Strategy.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) else Strategy.Machinings[i].bToolInvert = true Strategy.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, true, false) Strategy.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) end Strategy.Machinings[i].ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) Strategy.Machinings[i].ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) Strategy.Machinings[i].dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) Strategy.Machinings[i].vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) Strategy.Machinings[i].dLengthOnX = Proc.b3Box:getDimX() local MachiningToSplit = {} table.insert( MachiningToSplit, Strategy.Machinings[i]) local MachiningResult = MachiningLib.GetSplitMachinings( MachiningToSplit, FeatureSplittingPoints, Part) -- aggiunge lavorazione for j = 1, #MachiningResult do bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, MachiningResult[j]) end end else bAreAllMachiningsAdded = false end return bAreAllMachiningsAdded, Strategy.Result end ------------------------------------------------------------------------------------------------------------- return STR0009