Prima versione funzionante foratura. Per ora gestisce solo lavorazione con punta a forare
This commit is contained in:
+103
-1
@@ -415,7 +415,109 @@ end
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche
|
||||
-- TODO da fare
|
||||
function MachiningLib.FindDrill()
|
||||
function MachiningLib.FindDrill( Proc, ToolSearchParameters)
|
||||
local ToolInfo = {}
|
||||
local nBestToolIndex
|
||||
local dBestToolResidualDepth = 0
|
||||
|
||||
-- settio valori obbligatori
|
||||
if not ToolSearchParameters.dToolDiameter then
|
||||
ToolSearchParameters.dToolDiameter = Proc.FeatureInfo.dDrillDiam or 0
|
||||
end
|
||||
if not ToolSearchParameters.dMaxToolDiameter then
|
||||
ToolSearchParameters.dMaxToolDiameter = ToolSearchParameters.dToolDiameter + 100 * GEO.EPS_SMALL
|
||||
end
|
||||
if not ToolSearchParameters.dMinToolDiameter then
|
||||
ToolSearchParameters.dMinToolDiameter = ToolSearchParameters.dToolDiameter - 100 * GEO.EPS_SMALL
|
||||
end
|
||||
|
||||
for i = 1, #TOOLS do
|
||||
-- prima verifico che utensile sia compatibile
|
||||
local bIsToolCompatible = true
|
||||
-- se non è punta, non è compatibile
|
||||
if TOOLS[i].sFamily ~= 'DRILLBIT' then
|
||||
bIsToolCompatible = false
|
||||
-- se viene passato il nome, tutti gli altri sono incompatibili
|
||||
elseif ToolSearchParameters.sName and ToolSearchParameters.sName ~= TOOLS[i].sName then
|
||||
bIsToolCompatible = false
|
||||
-- controlli standard
|
||||
elseif TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then
|
||||
bIsToolCompatible = false
|
||||
elseif TOOLS[i].dDiameter < ToolSearchParameters.dMinToolDiameter then
|
||||
bIsToolCompatible = false
|
||||
elseif TOOLS[i].SetupInfo.HeadType.bTop and
|
||||
ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) - GEO.EPS_ZERO then
|
||||
bIsToolCompatible = false
|
||||
elseif TOOLS[i].SetupInfo.HeadType.bBottom and
|
||||
ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) + GEO.EPS_ZERO then
|
||||
bIsToolCompatible = false
|
||||
end
|
||||
|
||||
-- scelgo il migliore
|
||||
if bIsToolCompatible then
|
||||
-- calcolo riduzione del massimo materiale utilizzabile
|
||||
local ToolEntryAngle = GetToolEntryAngle( Proc, ToolSearchParameters.vtToolDirection)
|
||||
-- se ToolHolder più grande dell'utensile, il primo oggetto in collisione è il ToolHolder. Altrimenti il motore.
|
||||
local dDimObjToCheck = EgtIf( TOOLS[i].ToolHolder.dDiameter > TOOLS[i].dDiameter, TOOLS[i].ToolHolder.dDiameter, TOOLS[i].SetupInfo.dCAxisEncumbrance)
|
||||
local dCurrentMaxMatReduction = BeamData.COLL_SIC or 5
|
||||
|
||||
-- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom)
|
||||
-- TODO considerare anche il caso in cui lo stelo sia più grande del diametro utensile
|
||||
-- TODO nei confronti tra valori gestire tolleranze
|
||||
-- calcolo riduzione per non toccare con ToolHolder / Motore
|
||||
if ToolEntryAngle.dValue > 0 and ToolEntryAngle.dValue < 90 then
|
||||
dCurrentMaxMatReduction = dCurrentMaxMatReduction / ToolEntryAngle.dSin + ( ( dDimObjToCheck - TOOLS[i].dDiameter) / 2) / ToolEntryAngle.dTan
|
||||
end
|
||||
-- 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
|
||||
if not nBestToolIndex or ( dBestToolResidualDepth > 0 and dCurrentResidualDepth <= 0) then
|
||||
nBestToolIndex = i
|
||||
dBestToolResidualDepth = dCurrentResidualDepth
|
||||
-- altrimenti scelgo il migliore
|
||||
else
|
||||
-- se entrambi completi
|
||||
if dBestToolResidualDepth <= 0 and dCurrentResidualDepth <= 0 then
|
||||
-- se il migliore era su aggregato e corrente montanto direttamente, prediligo utensile montato direttamente
|
||||
if not TOOLS[i].SetupInfo.bToolOnAggregate and TOOLS[nBestToolIndex].SetupInfo.bToolOnAggregate then
|
||||
nBestToolIndex = i
|
||||
dBestToolResidualDepth = dCurrentResidualDepth
|
||||
-- se hanno stesso montaggio
|
||||
elseif TOOLS[i].SetupInfo.bToolOnAggregate == TOOLS[nBestToolIndex].SetupInfo.bToolOnAggregate then
|
||||
-- se diametro diverso
|
||||
if abs( TOOLS[i].dDiameter - TOOLS[nBestToolIndex].dDiameter) > 10 * GEO.EPS_SMALL then
|
||||
-- si sceglie utensile dello stesso diametro del foro da lavorare
|
||||
if abs( TOOLS[i].dDiameter - ToolSearchParameters.dToolDiameter) < 10 * GEO.EPS_SMALL then
|
||||
nBestToolIndex = i
|
||||
dBestToolResidualDepth = dCurrentResidualDepth
|
||||
-- oppure utensile con performance maggiore
|
||||
elseif TOOLS[i].dPerformanceIndex > TOOLS[nBestToolIndex].dPerformanceIndex then
|
||||
nBestToolIndex = i
|
||||
BestToolResidualDepth = dCurrentResidualDepth
|
||||
end
|
||||
-- scelgo utensile con indice di bontà utensile calcolato come: lunghezza / massimo materiale / diametro
|
||||
elseif TOOLS[i].dPerformanceIndex > TOOLS[nBestToolIndex].dPerformanceIndex then
|
||||
nBestToolIndex = i
|
||||
dBestToolResidualDepth = dCurrentResidualDepth
|
||||
end
|
||||
end
|
||||
-- se entrambi incompleti
|
||||
elseif dBestToolResidualDepth > 0 and dCurrentResidualDepth > 0 then
|
||||
--scelgo quello che lavora di più
|
||||
if dCurrentResidualDepth < dBestToolResidualDepth then
|
||||
nBestToolIndex = i
|
||||
dBestToolResidualDepth = dCurrentResidualDepth
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ToolInfo.nToolIndex = nBestToolIndex
|
||||
ToolInfo.dResidualDepth = dBestToolResidualDepth
|
||||
|
||||
return ToolInfo
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user