-- Strategia: STR0002 -- Descrizione -- Svuotatura tasca -- Feature: -- Slot -- FrontSlot -- IsRidgeLap -- IsLapJoint -- IsNotchRabbet -- IsNotch -- IsPocket -- Topology: 'Pocket-5-Blind' -- 'Groove-4-Blind' -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureData = require( 'FeatureData') -- Tabella per definizione modulo local STR0002 = {} local Strategy = {} ------------------------------------------------------------------------------------------------------------- local function IsTopologyOk( Proc) if Proc.Topology.sName == 'Pocket-5-Blind' or Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Groove-3-Through' then return true else return false end end ------------------------------------------------------------------------------------------------------------- function STR0002.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 = require( 'STR0002\\STR0002Config') Strategy.sName = StrategyLib.Config.sStrategyId CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) Strategy.Result = {} if not IsTopologyOk( Proc) then local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.Config.sStrategyId .. ' not implemented' EgtOutLog( sErr) Strategy.Result.sStatus = 'Not-Applicable' Strategy.Result.nCompletionIndex = 0 Strategy.Result.dMRR = 0 Strategy.Result.nQuality = 0 Strategy.Result.sInfo = sErr return false, Strategy.Result end local bApplyMachiningOK = true local ToolInfo = {} local Pocketing = {} Pocketing.Steps = {} Pocketing.LeadIn = {} Pocketing.LeadOut = {} -- serve utensile che possa lavorare di testa local ToolSearchParameters = {} ToolSearchParameters.sType = 'MILL_STD' ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth) ToolSearchParameters.dElevation = Proc.MainFaces.BottomFace.dElevation ToolSearchParameters.vtToolDir = Proc.MainFaces.BottomFace.vtN -- cerco utensile ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) if ToolInfo.nToolIndex and TOOLS[ToolInfo.nToolIndex].sName then if ToolInfo.dResidualDepth > 0 then Strategy.Result.sStatus = 'Not-Completed' else Strategy.Result.sStatus = 'Completed' end local dCompletionPercentage = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation - ToolInfo.dResidualDepth) / Proc.MainFaces.BottomFace.dElevation) * 100) Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( dCompletionPercentage) Strategy.Result.nQuality = FeatureData.GetFeatureQuality( 'Mill') Strategy.Result.dMRR = MachiningLib.GetToolMRR( TOOLS[ToolInfo.nToolIndex].dStep, TOOLS[ToolInfo.nToolIndex].dSideStep, TOOLS[ToolInfo.nToolIndex].Feeds.dFeed) Strategy.Result.sInfo = '' -- se richiesto applico lavorazione if bAddMachining then -- TODO gestione spezzatura da completare -- le lunghezza richiede spezzatura if ( Proc.b3Box:getDimX() > BeamData.LONGCUT_MAXLEN) or ( Proc.b3Box:getDimX() > 0.7 * Part.b3Solid:getDimX() and Proc.b3Box:getDimX() > BeamData.LONGCUT_ENDLEN) then -- recupero gruppo per geometria aggiuntiva local nAddGrpId = BeamLib.GetAddGroup( Part.idPart) local vAddId = {} local bStartLeft, bStartRight -- se feature inizia al di sotto del limite sinistro if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN then bStartLeft = true end -- se feature inizia al di sotto del limite destro if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN then bStartRight = true end -- salvo valori local dNewMinX = Proc.b3Box:getMin():getX() local dNewMaxX = Proc.b3Box:getMax():getX() local dNewRest = Proc.b3Box:getDimX() -- creo primo spezzone sulla sinistra if bStartLeft then local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL dNewMinX = max( ( Proc.b3Box:getMin():getX() + TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN) local ptOn = Point3d( dNewMinX, 0, 0) dNewRest = abs( dNewMaxX - dNewMinX) -- taglio della superficie lato sinistro EgtCutSurfTmPlane( AddId, ptOn, X_AX(), true, GDB_RT.GLOB) -- eseguo inserimento table.insert( vAddId, AddId) end -- creo spezzone sulla destra if bStartRight then local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL dNewMaxX = min( ( Proc.b3Box:getMax():getX() - TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN) local ptOn = Point3d( dNewMaxX, 0, 0) dNewRest = abs( dNewMaxX - dNewMinX) -- taglio della superficie lato destro EgtCutSurfTmPlane( AddId, ptOn, -X_AX(), true, GDB_RT.GLOB) -- eseguo inserimento table.insert( vAddId, EgtIf( BeamData.RIGHT_LOAD, 2, 1),AddId) end -- lavoro il restante local nSplitParts = max( ceil( dNewRest / BeamData.LONGCUT_MAXLEN + 10 * GEO.EPS_SMALL), 2) local dSplitPartsLen = dNewRest / nSplitParts for i = 1, nSplitParts do local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL local ptOn -- eseguo trim sinistro if i ~= 1 or bStartLeft then ptOn = Point3d( dNewMinX, 0, 0) -- taglio della superficie lato sinistro EgtCutSurfTmPlane( AddId, ptOn, -X_AX(), true, GDB_RT.GLOB) end -- eseguo trim destro dNewMaxX = dNewMinX + dSplitPartsLen if i ~= nSplitParts or bStartRight then ptOn = Point3d( dNewMaxX, 0, 0) -- taglio della superficie lato destro EgtCutSurfTmPlane( AddId, ptOn, X_AX(), true, GDB_RT.GLOB) end -- il nuovo minimo è il punto massimo del precedente dNewMinX = dNewMaxX -- eseguo inserimento in modo da ordinare da X- a X+ table.insert( vAddId, EgtIf( BeamData.RIGHT_LOAD, 1+i, EgtIf( bStartLeft, 1, 2)), AddId) end -- si applicano le lavorazioni for i = 1, #vAddId do Pocketing.nToolIndex = ToolInfo.nToolIndex Pocketing.nType = MCH_OY.POCKETING Pocketing.Steps.dStep = TOOLS[ToolInfo.nToolIndex].dStep Pocketing.dDepth = min( 0, -ToolInfo.dResidualDepth) Pocketing.Steps.dSideStep = TOOLS[ToolInfo.nToolIndex].dSideStep Pocketing.nSubType = MCH_POCK_SUB.SPIRALOUT Pocketing.LeadIn.nType = MCH_POCK_LI.ZIGZAG Pocketing.LeadIn.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter/2 Pocketing.LeadIn.dElevation = TOOLS[ToolInfo.nToolIndex].dDiameter/2 -- TODO settare parametro per indicare qual è lo spezzone che deve essere fatto dopo il taglio di separazione for j=1, Proc.nFct do local vtNSplitFace _, vtNSplitFace = EgtSurfTmFacetCenter( vAddId[i], j - 1, GDB_ID.ROOT) if vtNSplitFace and AreSameVectorExact( vtNSplitFace, Proc.MainFaces.BottomFace.vtN) then Pocketing.idFaceToMachine = j - 1 Pocketing.idProc = vAddId[i] bApplyMachiningOK, Strategy.Result.sInfo = MachiningLib.AddNewMachining( Pocketing) break end end end else Pocketing.nToolIndex = ToolInfo.nToolIndex Pocketing.nType = MCH_OY.POCKETING Pocketing.Steps.dStep = TOOLS[ToolInfo.nToolIndex].dStep Pocketing.dDepth = min( 0, -ToolInfo.dResidualDepth) Pocketing.Steps.dSideStep = TOOLS[ToolInfo.nToolIndex].dSideStep Pocketing.nSubType = MCH_POCK_SUB.SPIRALOUT Pocketing.LeadIn.nType = MCH_POCK_LI.ZIGZAG Pocketing.LeadIn.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter/2 Pocketing.LeadIn.dElevation = TOOLS[ToolInfo.nToolIndex].dDiameter/2 Pocketing.idFaceToMachine = Proc.MainFaces.BottomFace.id Pocketing.idProc = Proc.id bApplyMachiningOK, Strategy.Result.sInfo = MachiningLib.AddNewMachining( Pocketing) end end else Strategy.Result.sStatus = 'Not-Applicable' Strategy.Result.nCompletionIndex = 0 Strategy.Result.dMRR = 0 Strategy.Result.nQuality = 0 Strategy.Result.sInfo = 'Mill not found' bApplyMachiningOK = false end return bApplyMachiningOK, Strategy.Result end ------------------------------------------------------------------------------------------------------------- return STR0002