This commit is contained in:
luca.mazzoleni
2025-02-27 14:29:58 +01:00
5 changed files with 271 additions and 10 deletions
+2
View File
@@ -216,6 +216,7 @@ local function GetStrategies_Egalware( Proc)
---------------------------------------------------------------------
-- Feature : Dovetail Tenon
elseif ID.IsDovetailTenon( Proc) then
Strategies = { { sStrategyId = 'STR0001'}}
---------------------------------------------------------------------
-- Feature : Dovetail Mortise
elseif ID.IsDovetailMortise( Proc) then
@@ -474,6 +475,7 @@ local function GetStrategies_Essetre( Proc)
---------------------------------------------------------------------
-- Feature : Dovetail Tenon
elseif ID.IsDovetailTenon( Proc) then
Strategies = { { sStrategyId = 'STR0001'}}
---------------------------------------------------------------------
-- Feature : Dovetail Mortise
elseif ID.IsDovetailMortise( Proc) then
+1 -1
View File
@@ -140,7 +140,7 @@ function BeamExec.GetToolsFromDB()
Tool.dStemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ToolHolder.dDiameter -- se non settato, considero diametro come ToolHolder
Tool.dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0
-- verifico che parametri siano compatibili con una fresa a coda di rondine ( angolo di fianco standard Coda di rondine -> 15°)
Tool.bIsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.dSideAngle) - SIDEANGLE_DOVETAIL) < 1
Tool.bIsDoveTail = Tool.sType == 'MILL_NOTIP' and abs( abs( Tool.dSideAngle) - SIDEANGLE_DOVETAIL) < 1
-- verifico che sia una fresa tipo T-Mill o BlockHaus
Tool.dSideDepth = EgtGetValInNotes( Tool.sUserNotes, 'SIDEDEPTH', 'd') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale
Tool.bIsTMill = Tool.dSideDepth > 0
+67
View File
@@ -209,6 +209,19 @@ function FeatureLib.ClassifyTopology( Proc, Part)
return FeatureTopology
end
-------------------------------------------------------------------------------------------------------------
function FeatureLib.GetAdditionalInfo( Proc, Part)
-- se foro calcolo altri dati
if ID.IsDrilling( Proc) then
-- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento)
Proc.dDiam, Proc.dLen, Proc.nFcs, Proc.nFce = FeatureLib.GetDrillingData( Proc)
elseif ID.IsDovetailTenon( Proc) then
Proc.dDTLength, Proc.dDTMaxDist, Proc.vtDTNormal, Proc.ptDTCenter, Proc.idAddAuxGeom = FeatureLib.GetDoveTailTenonData( Proc)
end
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro e adattamento se speciale
function FeatureLib.GetDrillingData( Proc)
@@ -230,6 +243,60 @@ function FeatureLib.GetDrillingData( Proc)
return dDiam, dLen, nFcs, nFce
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati tenone a coda di rondine
function FeatureLib.GetDoveTailTenonData( Proc)
-- recupero e verifico l'entità curva
local idAux = EgtGetInfo( Proc.id, 'AUXID', 'i')
if idAux then idAux = idAux + Proc.id end
-- recupero i dati della curva
local vtExtr = EgtCurveExtrusion( idAux, GDB_RT.GLOB)
local ptBC = EgtGP( idAux, GDB_RT.GLOB)
-- determino altezza del tenone
local frDtTen = Frame3d( ptBC, vtExtr)
local b3DtTen = EgtGetBBoxRef( Proc.id, GDB_BB.STANDARD, frDtTen)
local dDtTenH = b3DtTen:getDimZ()
-- assegno centro e normale della faccia top
local vtN = vtExtr
local ptC = ptBC + vtN * dDtTenH
-- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0)
local dMaxDist
for i = 0, Proc.nFct - 1 do
local ptFC, vtFN = EgtSurfTmFacetCenter( Proc.id, i, GDB_ID.ROOT)
if not AreSameVectorApprox( vtFN, vtN) or abs( ( ptFC - ptBC) * vtN) > 100 * GEO.EPS_SMALL then
break
end
local nLoopId, nLoopCnt = EgtExtractSurfTmFacetLoops( Proc.id, i, EgtGetParent( Proc.id))
if nLoopId then
local dUmin, dUmax = EgtCurveDomain( nLoopId)
for dU = dUmin, dUmax do
local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT)
local ptNear = EgtNP( idAux, ptP, GDB_ID.ROOT)
local dDist = dist( ptP, ptNear)
if not dMaxDist or dDist > dMaxDist then
dMaxDist = dDist
end
end
for j = 1, nLoopCnt do
EgtErase( nLoopId + j - 1)
end
end
end
if not dMaxDist then
local b3DtAux = EgtGetBBoxRef( idAux, GDB_BB.STANDARD, frDtTen)
dMaxDist = 2 * ( b3DtTen:getRadius() - b3DtAux:getRadius())
end
Proc.dDTLength = dDtTenH
Proc.dDTMaxDist = dMaxDist
Proc.vtDTNormal = vtExtr
Proc.ptDTCenter = ptC
Proc.idAddAuxGeom = idAux
return Proc.dDTLength, Proc.dDTMaxDist, Proc.vtDTNormal, Proc.ptDTCenter, Proc.idAddAuxGeom
end
-------------------------------------------------------------------------------------------------------------
-- funzione che restituisce indice di completamento in base alla percentuale di volume lavorato
function FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage)
+3 -3
View File
@@ -214,7 +214,7 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters)
elseif TOOLS[i].bIsProfiledTool then
bIsToolCompatible = false
-- controlli standard
elseif TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then
elseif ToolSearchParameters.dMaxToolDiameter and TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then
bIsToolCompatible = false
elseif TOOLS[i].SetupInfo.dMinNz and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.dMinNz - GEO.EPS_ZERO then
bIsToolCompatible = false
@@ -228,7 +228,7 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters)
bIsToolCompatible = false
elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[i].bIsPen then
bIsToolCompatible = false
elseif TOOLS[i].sType ~= ToolSearchParameters.sType then
elseif ToolSearchParameters.sType and TOOLS[i].sType ~= ToolSearchParameters.sType then
-- se sto cercando una fresa che non può lavorare di testa, quelle che lavorano di testa sono comunque ammesse
if TOOLS[i].sType == 'MILL_STD' and ToolSearchParameters.sType == 'MILL_NOTIP' then
bIsToolCompatible = true
@@ -252,7 +252,7 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters)
if ToolEntryAngle.dValue > 0 and ToolEntryAngle.dValue < 90 then
dCurrentMaxMatReduction = dCurrentMaxMatReduction / ToolEntryAngle.dSin + ( ( dDimObjToCheck - TOOLS[i].dDiameter) / 2) / ToolEntryAngle.dTan
end
-- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili
-- dCurrentResidualDepth = negativo -> mm extra disponibili, positivo -> limitare
local dCurrentResidualDepth = ToolSearchParameters.dElevation + dCurrentMaxMatReduction - TOOLS[i].dMaxDepth
-- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore
+198 -6
View File
@@ -5,18 +5,210 @@
-- 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( AddMachining, 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')
CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters)
StrategyParameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters)
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
-------------------------------------------------------------------------------------------------------------