Merge remote-tracking branch 'origin/develop' into STR0003_BladePlusChainsaw

This commit is contained in:
luca.mazzoleni
2024-05-17 18:47:42 +02:00
2 changed files with 46 additions and 37 deletions
+22 -15
View File
@@ -66,25 +66,25 @@ function MachiningLib.GetMachiningSteps( dMachiningDepth, dStep)
return MachiningSteps
end
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo FRESA con certe caratteristiche
function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, vtToolDir)
function MachiningLib.FindMill( Proc, ToolSearchParameters)
local ToolInfo = {}
for nCurrIndex=1, #TOOLS do
-- prima verifico che utensile sia compatibile
local bCompatibleTool = true
if TOOLS[nCurrIndex].sType ~= sMillType then
if TOOLS[nCurrIndex].sType ~= ToolSearchParameters.sType then
bCompatibleTool = false
elseif TOOLS[nCurrIndex].dDiameter > dMaxToolDiameter then
elseif TOOLS[nCurrIndex].dDiameter > ToolSearchParameters.dMaxToolDiameter then
bCompatibleTool = false
elseif sMillShape == 'STANDARD' and ( TOOLS[nCurrIndex].dSideAngle ~= 0 or TOOLS[nCurrIndex].bIsPen) then
elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[nCurrIndex].dSideAngle ~= 0 or TOOLS[nCurrIndex].bIsPen) then
bCompatibleTool = false
elseif sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then
elseif ToolSearchParameters.sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then
bCompatibleTool = false
elseif sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then
elseif ToolSearchParameters.sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then
bCompatibleTool = false
elseif sMillShape == 'PEN' and not TOOLS[nCurrIndex].bIsPen then
elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[nCurrIndex].bIsPen then
bCompatibleTool = false
-- TODO controllare montaggio e verificare se direzione utensile raggiungibile. Serve funzione in BeamData
end
@@ -92,7 +92,7 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d
-- scelgo il migliore
if bCompatibleTool then
-- calcolo riduzione del massimo materiale utilizzabile
local dToolEntryAngle = GetToolEntryAngle( Proc, vtToolDir)
local dToolEntryAngle = GetToolEntryAngle( Proc, ToolSearchParameters.vtToolDir)
-- se ToolHolder più grande dell'utensile, il primo oggetto in collisione è il ToolHolder. Altrimenti il motore.
local dDimObjToCheck = EgtIf( TOOLS[nCurrIndex].ToolHolder.dDiameter > TOOLS[nCurrIndex].dDiameter, TOOLS[nCurrIndex].ToolHolder.dDiameter, BeamData.C_SIMM_ENC)
local dCurrMaxMatReduction = BeamData.COLL_SIC or 5
@@ -102,26 +102,26 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d
dCurrMaxMatReduction = dCurrMaxMatReduction / cos( 90 - dToolEntryAngle) + ( ( dDimObjToCheck - TOOLS[nCurrIndex].dDiameter) / 2) / tan( dToolEntryAngle)
end
-- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili
local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - dElevation - dCurrMaxMatReduction
local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - ToolSearchParameters.dElevation - dCurrMaxMatReduction
-- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore
if not ToolInfo.idTool or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then
ToolInfo.idTool = nCurrIndex
if not ToolInfo.nToolIndex or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then
ToolInfo.nToolIndex = nCurrIndex
ToolInfo.dMaxMatReduction = dCurrMachReduction
-- altrimenti scelgo il migliore
else
-- se entrambi completi
if ToolInfo.dMaxMatReduction > 0 and dCurrMachReduction > 0 then
-- scelgo utensile con rapporto lunghezza / diametro minore
if ( TOOLS[nCurrIndex].dLength / pow( TOOLS[nCurrIndex].dDiameter, 1.5)) < ( TOOLS[ToolInfo.idTool].dLength / pow( TOOLS[ToolInfo.idTool].dDiameter, 1.5)) then
ToolInfo.idTool = nCurrIndex
if ( TOOLS[nCurrIndex].dLength / pow( TOOLS[nCurrIndex].dDiameter, 1.5)) < ( TOOLS[ToolInfo.nToolIndex].dLength / pow( TOOLS[ToolInfo.nToolIndex].dDiameter, 1.5)) then
ToolInfo.nToolIndex = nCurrIndex
ToolInfo.dMaxMatReduction = dCurrMachReduction
end
-- se entrambi incompleti
elseif ToolInfo.dMaxMatReduction < 0 and dCurrMachReduction < 0 then
--scelgo quello che lavora di più
if dCurrMachReduction > ToolInfo.dMaxMatReduction then
ToolInfo.idTool = nCurrIndex
ToolInfo.nToolIndex = nCurrIndex
ToolInfo.dMaxMatReduction = dCurrMachReduction
end
end
@@ -189,5 +189,12 @@ end
-- TODO da fare
function MachiningLib.FindChainSaw()
end
-------------------------------------------------------------------------------------------------------------
-- funzione per aggiungere una nuova lavorazione
-- TODO da fare
function MachiningLib.AddNewMachining( Machining)
end
-------------------------------------------------------------------------------------------------------------
return MachiningLib
+24 -22
View File
@@ -50,21 +50,23 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
local ToolInfo = {}
-- serve utensile che possa lavorare di testa
local sMillType = 'MILL_STD'
local sMillShape = 'STANDARD'
local dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth)
local dElevation = Proc.MainFaces.BottomFace.dElevation
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, sMillType, sMillShape, dMaxToolDiameter, dElevation, Proc.MainFaces.BottomFace.vtN)
ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
if ToolInfo.idTool and TOOLS[ToolInfo.idTool].sName then
if ToolInfo.nToolIndex and TOOLS[ToolInfo.nToolIndex].sName then
if ToolInfo.dMaxMatReduction < 0 then
Strategy.RatingResult.sStatus = 'Not-Completed'
else
Strategy.RatingResult.sStatus = 'Completed'
end
Strategy.RatingResult.dCompletionIndex = min( 100, ( ( dElevation + ToolInfo.dMaxMatReduction) / dElevation) * 100)
Strategy.RatingResult.dCompletionIndex = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation + ToolInfo.dMaxMatReduction) / Proc.MainFaces.BottomFace.dElevation) * 100)
Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'Mill', Strategy.RatingResult.dCompletionIndex)
Strategy.RatingResult.sInfo = ''
@@ -93,8 +95,8 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
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.idTool].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN)
local AddId = EgtCopyGlob( Proc.iod, 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
@@ -104,8 +106,8 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
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.idTool].dDiameter * 2), Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN)
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
@@ -117,7 +119,7 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
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 AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL
local ptOn
-- eseguo trim sinistro
if i ~= 1 or bStartLeft then
@@ -139,14 +141,14 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
end
-- si applicano le lavorazioni
for i = 1, #vAddId do
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.idTool].sName)
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.idTool].dStep)
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName)
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep)
EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction))
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.idTool].dSideStep)
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep)
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG)
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.idTool].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.idTool].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
for j=1, Proc.nFct do
local vtNSplitFace
_, vtNSplitFace = EgtSurfTmFacetCenter( vAddId[i], j - 1, GDB_ID.ROOT)
@@ -158,14 +160,14 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
end
end
else
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.idTool].sName)
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.idTool].dStep)
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName)
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep)
EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction))
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.idTool].dSideStep)
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep)
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG)
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.idTool].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.idTool].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
EgtSetMachiningGeometry( {{ Proc.id, Proc.MainFaces.BottomFace.id}})
EgtApplyMachining( true, true)
end