- Aggiunta possibilità di fare taglio di sgrezzatura con fresa

- Prima versione gestione Result
- Altre modifiche minori
This commit is contained in:
andrea.villa
2025-09-19 12:47:20 +02:00
parent aa543fdf2d
commit ed1de946c1
2 changed files with 144 additions and 53 deletions
+1 -1
View File
@@ -45,7 +45,7 @@
{
"sName": "bExecRough",
"sNameNge": "EXEC_ROUGH",
"sValue": "0",
"sValue": "true",
"sDescriptionShort": "Execute cut to remove material",
"sDescriptionLong": "",
"sType": "b",
+143 -52
View File
@@ -82,8 +82,46 @@ local function GetRoughStrategy( Proc, Part, bSaveAddedGeometries)
Machining, Result = BladeToWaste.Make( AddId, Part, OptionalParameters)
-- se non ci sono lavorazioni, provo con fresa
if not Machining then
-- TODO
if not Machining or #Machining == 0 then
Machining.bCuttingWithMill = true
-- === ricerca utensile per svuotare taglio iniziale, se taglio non possibile ===
if not( Proc.AffectedFaces.bLeft) or Strategy.bCanMoveAfterSplit then
ToolSearchParameters = {}
-- TODO SISTEMARE!!! qui la svuotatura non deve limitare l'elevazione se aperta da tutti i lati. In futuro si deve passare 0 come elevazione
ToolSearchParameters.dElevation = EgtSurfTmFacetElevationInBBox( AddId, 0, Part.b3Part, true, GDB_ID.ROOT)
ToolSearchParameters.vtToolDirection = vtNP
ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sPocketingList, 'Pocketing')
Machining.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
-- TODO anche il test sul ResidualDepth va tolto
if Machining.ToolInfo.nToolIndex and ( Machining.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL) then
Machining.bIsApplicable = true
local ParametersMRR = {}
ParametersMRR.nToolIndex = Machining.ToolInfo.nToolIndex
Result.dMRR = MachiningLib.GetToolMRR( ParametersMRR)
Result.sStatus = 'Completed'
Machining.Steps = {}
Machining.LeadIn = {}
Machining.nType = MCH_MY.POCKETING
Machining.nSubType = MCH_POCK_SUB.SPIRALIN
Machining.LeadIn.nType = MCH_POCK_LI.ZIGZAG
Machining.Steps.dStep = TOOLS[Machining.ToolInfo.nToolIndex].dStep
Machining.Steps.dSideStep = TOOLS[Machining.ToolInfo.nToolIndex].dSideStep
Machining.nToolIndex = Machining.ToolInfo.nToolIndex
Machining.LeadIn.dTangentDistance = TOOLS[Machining.ToolInfo.nToolIndex].dDiameter/2
Machining.LeadIn.dElevation = TOOLS[Machining.ToolInfo.nToolIndex].dDiameter/2
Machining.sDepth = 0
Machining.Geometry = {{ AddId, 0}}
Machining.vtToolDirection = vtNP
if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then
Machining.sStage = 'AfterTail'
end
-- tempo di svuotatura
Result.dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machining, Part)
end
end
end
return Machining, Result
@@ -113,10 +151,9 @@ local function GetChamferStrategy( Proc, Part)
end
-------------------------------------------------------------------------------------------------------------
-- TODO gestire il caso in cui non si trova l'utensile
local function GetArcStrategy( Proc, Part)
local Machining = {}
local Result = {}
local Result = { dCompletionPercentage = 100}
local ToolSearchParameters = {}
-- recupero i dati della curva e del profilo
@@ -128,6 +165,7 @@ local function GetArcStrategy( Proc, Part)
local bIsFeatureBack = Proc.AffectedFaces.bBack and not Proc.AffectedFaces.bFront
local bForceStrip = Strategy.Parameters.bForceStrip
local dDimStrip = EgtIf( Strategy.Parameters.dStripWidth < 100 * GEO.EPS_SMALL, nil, Strategy.Parameters.dStripWidth)
local sMaxDepth = dDepth * 2
local bExecStrip = false
-- se la lavorazione si trova nella parte inferiore o in battuta dietro, il codolo va sempre lasciato
@@ -158,7 +196,6 @@ local function GetArcStrategy( Proc, Part)
if bIsHorizontal then
local bDouble
local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING)
Milling.bIsApplicable = false
ToolSearchParameters = {}
ToolSearchParameters.sMillShape = 'STANDARD'
ToolSearchParameters.dElevation = EgtIf( bExecStrip, ( dDepth - dDimStrip) / 2, dDepth + BeamData.MILL_OVERLAP)
@@ -169,38 +206,44 @@ local function GetArcStrategy( Proc, Part)
Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
-- se posso lavorare in una passata, ma utensile trovato non completa la lavorazione,
-- allora provo a cercare utensile con massimo materiale sufficiente per fare le due passate, magari trova un utensile più prestante
if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then
bDouble = true
ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2
ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr)
Milling.ToolInfo = {}
Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
end
Milling.vtToolDirection = ToolSearchParameters.vtToolDirection
if nCycle == 2 then
Milling.dRadialOffset = Strategy.Parameters.dOverMaterial
end
if bDouble or bExecStrip then
if bDouble then
Milling.sDepth = ( dDepth + BeamData.MILL_OVERLAP) / 2
else
Milling.sDepth = ( dDepth - dDimStrip) / 2
if Milling.ToolInfo.nToolIndex then
if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then
bDouble = true
ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2
Milling.ToolInfo = {}
Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
end
Milling.vtToolDirection = ToolSearchParameters.vtToolDirection
if nCycle == 2 then
Milling.dRadialOffset = Strategy.Parameters.dOverMaterial
end
-- se non completo
if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL then
sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth
-- si salva percentuala lavorata
Result.dCompletionPercentage = 100 - ceil( ( Milling.ToolInfo.dResidualDepth / ToolSearchParameters.dElevation) * 100)
end
if bDouble or bExecStrip then
if bDouble then
Milling.sDepth = min( sMaxDepth, ( dDepth + BeamData.MILL_OVERLAP) / 2)
else
Milling.sDepth = min( sMaxDepth, ( dDepth - dDimStrip) / 2)
end
table.insert( Machining, Milling)
local Milling2 = BeamLib.TableCopyDeep( Milling)
Milling2.bOtherDirection = true
table.insert( Machining, Milling2)
else
Milling.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP)
table.insert( Machining, Milling)
end
table.insert( Machining, Milling)
local Milling2 = BeamLib.TableCopyDeep( Milling)
Milling2.bOtherDirection = true
table.insert( Machining, Milling2)
else
Milling.sDepth = dDepth + BeamData.MILL_OVERLAP
table.insert( Machining, Milling)
end
-- se lavorazione verticale
else
-- si cerca utensile 1
local Milling = {}
Milling.bIsApplicable = false
ToolSearchParameters = {}
ToolSearchParameters.sMillShape = 'STANDARD'
ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP
@@ -209,6 +252,7 @@ local function GetArcStrategy( Proc, Part)
ToolSearchParameters.dMaxToolDiameter = nMaxDiamMill
Milling.ToolInfo = {}
Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
if nCycle == 2 then
Milling.dRadialOffset = Strategy.Parameters.dOverMaterial
end
@@ -216,7 +260,6 @@ local function GetArcStrategy( Proc, Part)
-- si cerca utensile 2
local Milling2 = {}
Milling2.bIsApplicable = false
ToolSearchParameters = {}
ToolSearchParameters.sMillShape = 'STANDARD'
ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP
@@ -270,25 +313,71 @@ local function GetArcStrategy( Proc, Part)
end
end
-- TODO VOTO DA FARE!!!!
Result.sStatus = 'Completed'
Result.nCompletionIndex = 5
Result.dMRR = 1
Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL')
Result.sInfo = ''
Machining.bIsApplicable = #Machining > 0
return Machining, Result
end
-------------------------------------------------------------------------------------------------------------
local function GetFeatureResult()
local Result = {}
local function GetFeatureResult( Proc)
local Result = { sStatus = 'Completed', dCompletionPercentage = 100, sInfo = ''}
local dPercentageChamfer = 10
local dPercentageEdgeCorner = 10
local dPercentageProfile = 80
Result.sStatus = 'Completed'
Result.nCompletionIndex = 5
-- se non ci sono lavorazioni di smusso
if not Strategy.Chamfer.Machinings or #Strategy.Chamfer.Machinings == 0 then
-- se esclusivo, non applicabile
if Strategy.Parameters.bOnlyChamfer then
Result = FeatureLib.GetStrategyResultNotApplicable( 'Not possible to machine chamfer only, tool not found!')
Result.dCompletionPercentage = 0
-- se non esclusivo, non completo
elseif Strategy.Parameters.dDepthChamfer > 10 * GEO.EPS_SMALL then
Result.dCompletionPercentage = Result.dCompletionPercentage - dPercentageChamfer -- gli smussi incidono per il 10%
dPercentageChamfer = 0
Result.sInfo = '- Chamfer not executed, tool not found!\n'
end
end
-- se richieste anche le altre lavorazioni
if not Strategy.Parameters.bOnlyChamfer then
-- per tutti tranne che per feature RoundArc
if not ID.IsRoundArch( Proc) then
-- se sgrossatura da eseguire
if Strategy.Parameters.bExecRough then
if not Strategy.RoughCut.Machinings or #Strategy.RoughCut.Machinings == 0 then
Result.dCompletionPercentage = Result.dCompletionPercentage -- non incide sulla percentuale lavorata, solo messaggio che manca
Result.sInfo = Result.sInfo .. '- Roughing not executed\n'
end
end
-- se lavorazioni corner
if not Strategy.EdgeWithCorner.Machinings or #Strategy.EdgeWithCorner.Machinings == 0 then
Result.dCompletionPercentage = Result.dCompletionPercentage - dPercentageEdgeCorner -- la pulizia dei corner incide per il 10%
dPercentageEdgeCorner = 0
Result.sInfo = Result.sInfo .. '- Corner not executed, material left\n'
end
end
-- lavorazione del profilo
if not Strategy.Profile.Machinings or #Strategy.Profile.Machinings == 0 then
Result.sInfo = Result.sInfo .. '- Profile not executed, tool not found!\n'
else
local dTotalPercentage = dPercentageProfile + dPercentageEdgeCorner + dPercentageChamfer
Result.dCompletionPercentage = Result.dCompletionPercentage - ( ( ( 100 - Strategy.Profile.Result.dCompletionPercentage) * dTotalPercentage) / 100)
end
end
-- si setta lo stato in base alla percentuale di completamento
if Result.dCompletionPercentage == 100 then
Result.sStatus = "Completed"
elseif Result.dCompletionPercentage == 0 then
Result.sStatus = "Not-Applicable"
else
Result.sStatus = "Not-Completed"
end
Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Result.dCompletionPercentage)
Result.dMRR = 1
Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL')
Result.sInfo = ''
return Result
end
@@ -328,15 +417,17 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters)
if not Strategy.Parameters.bOnlyChamfer then
-- per tutti tranne che per feature RoundArc
if not ID.IsRoundArch( Proc) then
Strategy.RoughCut = {}
Strategy.RoughCut.Machinings = {}
Strategy.RoughCut.Result = {}
-- lavorazione taglio per sgrossare
if Strategy.Parameters.bExecRough then
Strategy.RoughCut = {}
Strategy.RoughCut.Machinings = {}
Strategy.RoughCut.Result = {}
Strategy.RoughCut.Machinings, Strategy.RoughCut.Result = GetRoughStrategy( Proc, Part, bAddMachining)
end
-- lavorazione degli estremi con angoli interni
Strategy.EdgeWithCorner = {}
Strategy.EdgeWithCorner.Machinings = {}
Strategy.EdgeWithCorner.Result = {}
-- lavorazione taglio per sgrossare
Strategy.RoughCut.Machinings, Strategy.RoughCut.Result = GetRoughStrategy( Proc, Part, bAddMachining)
-- lavorazione degli estremi con angoli interni
Strategy.EdgeWithCorner.Machinings, Strategy.EdgeWithCorner.Result = GetEdgeWithCornerStrategy( Proc, Part)
end
@@ -347,7 +438,7 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters)
Strategy.Profile.Machinings, Strategy.Profile.Result = GetArcStrategy( Proc, Part)
end
Strategy.Result = GetFeatureResult()
Strategy.Result = GetFeatureResult( Proc)
if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then
-- eventuali punti di spezzatura
@@ -358,10 +449,10 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters)
end
-- lavorazione di sgrezzatura di lama
if Strategy.RoughCut.Machinings then
if Strategy.Parameters.bExecRough and Strategy.RoughCut.Machinings then
-- se cutting da fare come svuotatura
if Strategy.RoughCut.Machinings.bCuttingWithMill then
-- TODO
bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Strategy.RoughCut.Machinings)
-- taglio di lama
else
for i = 1, #Strategy.RoughCut.Machinings do