37f85bccec
- Aggiunta attacco lineare
216 lines
8.8 KiB
Lua
216 lines
8.8 KiB
Lua
-- Strategia: STR0001
|
|
-- Descrizione
|
|
-- Lama + fresa CodaDiRondine per tenone
|
|
-- Feature: 55,1
|
|
|
|
-- carico librerie
|
|
local BeamLib = require( 'BeamLib')
|
|
local BeamData = require( 'BeamData')
|
|
local MachiningLib = require( 'MachiningLib')
|
|
local FeatureLib = require( 'FeatureLib')
|
|
-- strategie di base
|
|
local FaceByBlade = require('FACEBYBLADE')
|
|
|
|
-- Tabella per definizione modulo
|
|
local STR0001 = {}
|
|
local Strategy = {}
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function STR0001.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( 'STR0001\\STR0001Config')
|
|
Strategy.sName = StrategyLib.Config.sStrategyId
|
|
CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters)
|
|
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters)
|
|
Strategy.Machining = {}
|
|
Strategy.Result = {}
|
|
|
|
|
|
local bAreAllMachiningsAdded = true
|
|
local ToolSearchParameters = {}
|
|
local Milling = {}
|
|
local Cutting = {}
|
|
local Pocketing = {}
|
|
|
|
-- ===== RICERCA UTENSILE =====
|
|
-- === ricerca utensile per taglio del tenone in lunghezza ===
|
|
-- TODO fare funzione generale per trovare lama data una faccia?
|
|
Cutting.bIsApplicable = false
|
|
ToolSearchParameters.bAllowTopHead = true
|
|
ToolSearchParameters.bAllowBottomHead = false
|
|
ToolSearchParameters.vtToolDirection = Proc.vtDTNormal
|
|
Cutting.ToolInfo = {}
|
|
Cutting.ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters)
|
|
if Cutting.ToolInfo.nToolIndex then
|
|
Cutting.bIsApplicable = true
|
|
local ParametersMRR = {}
|
|
ParametersMRR.nToolIndex = Cutting.ToolInfo.nToolIndex
|
|
Cutting.dMRR = MachiningLib.GetToolMRR( ParametersMRR)
|
|
end
|
|
|
|
-- === ricerca utensile per lavorare tenone coda di rondine ===
|
|
Milling.bIsApplicable = false
|
|
ToolSearchParameters.dElevation = Proc.dDTLength
|
|
ToolSearchParameters.vtToolDirection = Proc.vtDTNormal
|
|
ToolSearchParameters.sMillShape = 'DOVETAIL'
|
|
Milling.ToolInfo = {}
|
|
Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
|
|
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill')
|
|
if Milling.ToolInfo.nToolIndex then
|
|
Milling.bIsApplicable = true
|
|
local ParametersMRR = {}
|
|
ParametersMRR.nToolIndex = Milling.ToolInfo.nToolIndex
|
|
Milling.dMRR = MachiningLib.GetToolMRR( ParametersMRR)
|
|
end
|
|
|
|
-- === ricerca utensile di svuotatura (se richiesto) ===
|
|
-- se bastano passate con sovramateriale
|
|
local nMillingPathsNeeded = ceil( Proc.dDTMaxDist / TOOLS[Milling.ToolInfo.nToolIndex].dSideStep)
|
|
if nMillingPathsNeeded <= Strategy.Parameters.nMaxMillingPaths then
|
|
Pocketing.bNotNeeded = true
|
|
Pocketing.dMRR = Milling.dMRR
|
|
-- serve svuotatura
|
|
else
|
|
Pocketing.ToolInfo = {}
|
|
-- se ammessa svuotatura con utensile DoveTail, copio i dati
|
|
if Strategy.Parameters.bUseDTToolOnPocketing then
|
|
Pocketing.ToolInfo = Milling.ToolInfo
|
|
Pocketing.dMRR = Milling.dMRR
|
|
-- altrimenti serve cercarne un altro
|
|
else
|
|
ToolSearchParameters = {}
|
|
ToolSearchParameters.dElevation = Proc.dDTLength
|
|
ToolSearchParameters.vtToolDirection = Proc.vtDTNormal
|
|
Pocketing.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
|
|
end
|
|
-- se trovato utensile di svuotatura
|
|
if Pocketing.ToolInfo.nToolIndex then
|
|
Pocketing.bIsApplicable = true
|
|
end
|
|
end
|
|
|
|
-- setto il risultato in base agli utensili trovati
|
|
-- lavorazione completa
|
|
if Milling.bIsApplicable and Cutting.bIsApplicable and ( Pocketing.bIsApplicable or Pocketing.bNotNeeded) then
|
|
Strategy.Result.sStatus = 'Completed'
|
|
Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( 100)
|
|
Strategy.Result.dMRR = ( Milling.dMRR + Cutting.dMRR + Pocketing.dMRR) / 3
|
|
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill,Blade,Mill')
|
|
-- lavorazione incompleta
|
|
elseif Cutting.bIsApplicable then
|
|
Strategy.Result.sStatus = 'Not-Completed'
|
|
Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( 50)
|
|
Strategy.Result.dMRR = ( Milling.dMRR + Cutting.dMRR + Pocketing.dMRR) / 3
|
|
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill')
|
|
if not Milling.bIsApplicable then
|
|
Strategy.Result.sInfo = 'DoveTail-Mill not found'
|
|
else
|
|
Strategy.Result.sInfo = 'DoveTail tenon not completed'
|
|
end
|
|
-- strategia non applicabile, manca il taglio di lama sulla lunghezza del tenone
|
|
else
|
|
Strategy.Result.sStatus = 'Not-Applicable'
|
|
Strategy.Result.nCompletionIndex = 0
|
|
Strategy.Result.dMRR = 0
|
|
Strategy.Result.nQuality = 0
|
|
Strategy.Result.sInfo = 'Mill not found'
|
|
end
|
|
|
|
-- applicazione delle lavorazioni
|
|
if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then
|
|
-- creo piano di taglio sulla testa del tenone
|
|
local nAddGrpId = BeamLib.GetAddGroup( Part.id)
|
|
local idTenonCutPlane = EgtSurfTmPlaneInBBox( nAddGrpId, Proc.ptDTCenter, Proc.vtDTNormal, Part.b3Part, GDB_RT.GLOB)
|
|
if idTenonCutPlane then
|
|
EgtSetName( idTenonCutPlane, 'AddCut_' .. tostring( Proc.id))
|
|
EgtSetInfo( idTenonCutPlane, 'TASKID', Proc.idTask)
|
|
end
|
|
|
|
-- taglio in lunghezza sul tenone
|
|
if Cutting.bIsApplicable then
|
|
OptionalParameters = {}
|
|
local AuxiliaryData = {}
|
|
OptionalParameters.nToolIndex = Cutting.ToolInfo.nToolIndex
|
|
OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK
|
|
OptionalParameters.sDepth = 0
|
|
|
|
-- TODO gestire lavorazione a cubetti
|
|
|
|
-- TODO
|
|
-- Su faccia appena creata NON sono stati calcolati gli edges.
|
|
-- La FaceByBlade si aspetta di lavorare 1 faccia di una trimesh. Fare altra funzione?
|
|
|
|
--local nFaceType, vEdges = EgtSurfTmGetFacetOutlineInfo( AddId, 0, GDB_ID.ROOT)
|
|
--local EdgeToMachine = GetEdgeToMachine( vEdges, -Y_AX())
|
|
-- approccio e retrazione
|
|
--OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine)
|
|
--Cutting = FaceByBlade.Make( Proc, Part, AddId, EdgeToMachine, OptionalParameters)
|
|
if Proc.AffectedFaces.bLeft then
|
|
Cutting.sStage = 'AfterTail'
|
|
end
|
|
MachiningLib.AddNewMachining( Proc, Cutting, AuxiliaryData)
|
|
end
|
|
|
|
-- svuotatura
|
|
if Pocketing.bIsApplicable then
|
|
-- azzero eventuale contatore passaggi con sovramateriale
|
|
nMillingPathsNeeded = 1
|
|
end
|
|
|
|
-- passaggio sul profilo
|
|
if Milling.bIsApplicable then
|
|
local AuxiliaryData = {}
|
|
-- aggiungo geometria
|
|
Milling.Geometry = {{ Proc.idAddAuxGeom, -1}}
|
|
Milling.nToolIndex = Milling.ToolInfo.nToolIndex
|
|
Milling.nType = MCH_MY.MILLING
|
|
Milling.vtToolDirection = Proc.vtDTNormal
|
|
Milling.sDepth = 0
|
|
|
|
-- LeadIn / LeadOut
|
|
Milling.LeadIn = {}
|
|
Milling.LeadOut = {}
|
|
Milling.LeadIn.nType = MCH_MILL_LI.LINEAR
|
|
Milling.LeadOut.nType = MCH_MILL_LI.LINEAR
|
|
Milling.LeadIn.dTangentDistance = TOOLS[Milling.ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC
|
|
Milling.LeadIn.dPerpDistance = 0
|
|
Milling.LeadOut.dTangentDistance = TOOLS[Milling.ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC
|
|
Milling.LeadOut.dPerpDistance = 0
|
|
|
|
if Proc.AffectedFaces.bLeft then
|
|
Milling.sStage = 'AfterTail'
|
|
end
|
|
|
|
-- sistemo il lato e la direzione di lavoro
|
|
Milling.bInvert = EgtIf( TOOLS[Milling.ToolInfo.nToolIndex].bIsCCW, false, true)
|
|
Milling.nWorkside = EgtIf( TOOLS[Milling.ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT)
|
|
|
|
Milling.sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( Proc.dDTLength, 1)) .. ';'
|
|
|
|
-- TODO calcolare SCC
|
|
|
|
-- passate con sovramateriale
|
|
AuxiliaryData.Clones = {}
|
|
for i = nMillingPathsNeeded, 1, -1 do
|
|
-- il primo è il passaggio più esterno
|
|
local nIndexClones = nMillingPathsNeeded - i + 1
|
|
-- suddivido step in base al numero passate da fare
|
|
local dRealSideStep = floor( Proc.dDTMaxDist / nMillingPathsNeeded)
|
|
-- cambia solo sovrmateriale radiale
|
|
AuxiliaryData.Clones[nIndexClones] = {}
|
|
AuxiliaryData.Clones[nIndexClones].dRadialOffset = ( i - 1) * dRealSideStep
|
|
end
|
|
|
|
-- aggiunge lavorazione
|
|
bAreAllMachiningsAdded = MachiningLib.AddNewMachining( Proc, Milling, AuxiliaryData)
|
|
end
|
|
end
|
|
|
|
return bAreAllMachiningsAdded, Strategy.Result
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
return STR0001 |