Compare commits

..

4 Commits

Author SHA1 Message Date
daniele.nicoli 2bbe508711 in Drill - altra correzione 2026-08-24 15:42:17 +02:00
daniele.nicoli 4f060b89a4 in Drill - piccola correzione quando prova utensile alternativo per la lavorazione. 2026-08-24 15:14:10 +02:00
daniele.nicoli 188d119a16 Merge remote-tracking branch 'origin/develop' into test_Drill_Presimulation_Tool_Encumbrance 2026-08-24 13:34:42 +02:00
daniele.nicoli 4f24b32705 - PreSimulationLib - Unificata funzione per la pre simulazione della distanza tra punto e grezzo
-LeadInOutLib - unificata con funzione in PreSimulationLib
- STR0011 - Aggiunto calcolo per approccio in velocità di lavoro
- MachiningLib - Drill - Calcolo massima profondità del foro rispetto a portautensile
2026-07-28 17:07:30 +02:00
8 changed files with 137 additions and 79 deletions
-7
View File
@@ -36,9 +36,6 @@ function FeatureLib.GetProcFromTrimesh( idTrimesh, Part, ProcToCopyFrom)
if ProcToCopyFrom and Proc.dVolume < 10 * GEO.EPS_SMALL then
Proc.dVolume = ProcToCopyFrom.dVolume
end
Proc.nParts = EgtSurfTmPartCount( Proc.id) or 1
Proc.Topology = FeatureLib.ClassifyTopology( Proc, Part)
-- TODO servono anche altri dati raccolti nel collect??
return Proc
@@ -223,10 +220,6 @@ function FeatureLib.ClassifyTopology( Proc, Part)
elseif Proc.nFct == 1 and ( bIsFeatureCuttingEntireSection or bIsFeatureCuttingEntireLength) then
sFamily = 'Cut'
bIsThrough = true
-- se taglia intera sezione ed è rivolto verso la coda, bisogna considerare come se tocchi la faccia di coda
if Proc.Faces[1].vtN:getX() < 0 then
Proc.AffectedFaces.bLeft = true
end
elseif Proc.nFct == 1 then
sFamily = 'Bevel'
bIsThrough = true
+11 -14
View File
@@ -9,6 +9,7 @@ require( 'EgtBase')
local BeamData = require( 'BeamDataNew')
local FaceData = require( 'FaceData')
local BeamLib = require( 'BeamLib')
local PreSimulationLib = require( 'PreSimulationLib')
EgtOutLog( ' LeadInOutLib started', 1)
@@ -71,24 +72,20 @@ end
local function CalculateLeadInOutLength( ptToolCenter, vtNFace, b3Box, vtLeadInOut, Tool)
-- al momento gestita solo lama
if not Tool.sFamily == 'SawBlade' then
if not Tool.sFamily == 'SAWBLADE' then
error(' Tool family not implemented')
end
-- Box del pezzo espansi ortogonalmente alle tre direzioni canoniche X, Y e Z
local b3BoxX = BBox3d( b3Box) ; b3BoxX:expand( 0, 1000, 1000)
local b3BoxY = BBox3d( b3Box) ; b3BoxY:expand( 1000, 0, 1000)
local b3BoxZ = BBox3d( b3Box) ; b3BoxZ:expand( 1000, 1000, 0)
local ptStart = Point3d( ptToolCenter)
local DistanceData = {}
DistanceData.vtNFace = vtNFace
DistanceData.vtMove = vtLeadInOut
DistanceData.dToolThickness = Tool.dThickness
DistanceData.dToolDiameter = Tool.dDiameter
DistanceData.sToolFamily = Tool.sFamily
DistanceData.ptReferencePoint = ptStart + DistanceData.dToolThickness * DistanceData.vtNFace
-- si setta utensile lama per il controllo collisione
EgtCAvSetSawTool( Tool.dThickness, Tool.dDiameter, Tool.dThickness, 0, 0)
-- calcolo distanza di cui retrarre con funzioni Tool Collision Avoidance
local dLength = min( EgtCAvToolPosBox( ptToolCenter + Tool.dThickness * vtNFace, vtNFace, b3BoxX, vtLeadInOut),
EgtCAvToolPosBox( ptToolCenter + Tool.dThickness * vtNFace, vtNFace, b3BoxY, vtLeadInOut),
EgtCAvToolPosBox( ptToolCenter + Tool.dThickness * vtNFace, vtNFace, b3BoxZ, vtLeadInOut))
return dLength
return PreSimulationLib.GetDistanceToRetractToolFromRaw( DistanceData, b3Box)
end
+26
View File
@@ -791,6 +791,25 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters)
return ToolInfo
end
-- Calcolo profondità massima del foro rispetto al Portautensile (solo per utensile punta)
-------------------------------------------------------------------------------------------------------------
function MachiningLib.GetDrillMaxDepthFromToolHolderSideEncumbrance( FeatureInfo, nToolIndex, b3Raw)
local b3Box = BBox3d( b3Raw)
b3Box:expand( BeamData.COLL_SIC)
local ptStart = Point3d( FeatureInfo.ptDrillCenter)
local dToolLength = TOOLS[nToolIndex].dLength
local dMaxDepth = TOOLS[nToolIndex].dMaxDepth
local DistanceData = {}
DistanceData.vtNFace = Vector3d( FeatureInfo.vtDrillExtrusion)
DistanceData.vtMove = Vector3d( FeatureInfo.vtDrillExtrusion)
DistanceData.dToolLength = TOOLS[nToolIndex].ToolHolder.dLength
DistanceData.dToolDiameter = TOOLS[nToolIndex].ToolHolder.dDiameter
DistanceData.sToolFamily = 'TOOLHOLDER'
DistanceData.ptReferencePoint = ptStart + ( ( dToolLength - dMaxDepth - DistanceData.dToolLength) * DistanceData.vtNFace)
return PreSimulationLib.GetDistanceToRetractToolFromRaw( DistanceData, b3Box)
end
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche
function MachiningLib.FindDrill( Proc, ToolSearchParameters)
@@ -907,6 +926,13 @@ function MachiningLib.FindDrill( Proc, ToolSearchParameters)
ToolInfo.nToolIndex = nBestToolIndex
ToolInfo.dResidualDepth = dBestToolResidualDepth
if nBestToolIndex then
local dTHReduction = MachiningLib.GetDrillMaxDepthFromToolHolderSideEncumbrance( Proc.FeatureInfo, nBestToolIndex, ToolSearchParameters.Part.b3Raw)
local dTHResidualDepth = ToolSearchParameters.dElevation + dTHReduction - TOOLS[nBestToolIndex].dMaxDepth
if dTHResidualDepth < dBestToolResidualDepth then
ToolInfo.dResidualDepth = dTHResidualDepth
end
end
-- si salva se la punta ha lo stesso diametro del foro
if nBestToolIndex and TOOLS[nBestToolIndex].dDiameter - ToolSearchParameters.dToolDiameter > 100 * GEO.EPS_SMALL then
ToolInfo.bDrillIsExactDiameter = true
+29
View File
@@ -103,6 +103,35 @@ function PreSimulationLib.GetPointOnToolTipCenter( ptPointAtDepth, vtHead, vtNFa
return ptPointAtDepth + vtToolOffset * Tool.dDiameter / 2 + vtNFace * EgtIf( AreSameVectorApprox( vtHead, vtNFace), 0, Tool.dThickness)
end
-------------------------------------------------------------------------------------------------------------
function PreSimulationLib.GetDistanceToRetractToolFromRaw( DistanceData, b3Box)
-- Box del pezzo espansi ortogonalmente alle tre direzioni canoniche X, Y e Z
local b3BoxX = BBox3d( b3Box) ; b3BoxX:expand( 0, 1000, 1000)
local b3BoxY = BBox3d( b3Box) ; b3BoxY:expand( 1000, 0, 1000)
local b3BoxZ = BBox3d( b3Box) ; b3BoxZ:expand( 1000, 1000, 0)
-- Imposta l'utensile correttamente
if DistanceData.sToolFamily == 'DRILLBIT' then
-- si setta utensile Punta per il controllo collisione
EgtCAvSetAdvTool( DistanceData.dToolLength, DistanceData.dToolDiameter, ( DistanceData.dToolTotalLength - DistanceData.dToolLength), 0, 0)
elseif DistanceData.sToolFamily == 'SAWBLADE' then
-- si setta utensile Lama per il controllo collisione
EgtCAvSetSawTool( DistanceData.dToolThickness, DistanceData.dToolDiameter, DistanceData.dToolThickness, 0, 0)
elseif DistanceData.sToolFamily == 'TOOLHOLDER' then
-- si setta utensile Cilindrico per simulare il portautensile in caso di fori inclinati nei quali è possibile che il portautensile collida
EgtCAvSetStdTool( DistanceData.dToolLength, DistanceData.dToolDiameter, 0)
-- altre tipologie non gestite
else
return nil
end
-- calcolo distanza di cui retrarre con funzioni Tool Collision Avoidance *da top dell'utensile*
local dLength = min( EgtCAvToolPosBox( DistanceData.ptReferencePoint, DistanceData.vtNFace, b3BoxX, DistanceData.vtMove),
EgtCAvToolPosBox( DistanceData.ptReferencePoint, DistanceData.vtNFace, b3BoxY, DistanceData.vtMove),
EgtCAvToolPosBox( DistanceData.ptReferencePoint, DistanceData.vtNFace, b3BoxZ, DistanceData.vtMove))
return dLength
end
-------------------------------------------------------------------------------------------------------------
-- calcolo punto sull'uscita testa a partire dal punto di lavorazione o di attacco sul diametro utensile
local function GetToolExitPoint( ptMachining, vtNEdge, vtHead, Tool, bIsDownUp)
+4 -6
View File
@@ -316,11 +316,10 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters)
local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide
local dToolMarkLength = Milling1.dToolMarkLength or 0
local OptionalParameters = {
bIsSplitFeature = false, -- anche se feature splittata, le facce di chiusura si lavorano intere
bIsSplitFeature = bIsSplitFeature,
dExtendAfterTail = dExtendAfterTail,
dRadialStepSpan = dToolMarkLength,
dDepthToMachine = dDepthToMachine,
nStepType = MCH_MILL_ST.ONEWAY
dDepthToMachine = dDepthToMachine
}
local Milling = FaceByMill.Make( Proc, Part, BottomFace1, EdgesClosedNotMachined[i], OptionalParameters)
Milling.nInternalSortingPriority = 3
@@ -343,11 +342,10 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters)
local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide
local dToolMarkLength = Milling2.dToolMarkLength or 0
local OptionalParameters = {
bIsSplitFeature = false, -- anche se feature splittata, le facce di chiusura si lavorano intere
bIsSplitFeature = bIsSplitFeature,
dExtendAfterTail = dExtendAfterTail,
dRadialStepSpan = dToolMarkLength,
dDepthToMachine = dDepthToMachine,
nStepType = MCH_MILL_ST.ONEWAY
dDepthToMachine = dDepthToMachine
}
local Milling = FaceByMill.Make( Proc, Part, BottomFace2, EdgesClosedNotMachined[i], OptionalParameters)
Milling.nInternalSortingPriority = 3
+24 -1
View File
@@ -8,6 +8,7 @@ local BeamLib = require( 'BeamLib')
local BeamData = require( 'BeamDataNew')
local MachiningLib = require( 'MachiningLib')
local FeatureLib = require( 'FeatureLib')
local PreSimulationLib = require( 'PreSimulationLib')
-- strategie di base
-- Tabella per definizione modulo
@@ -37,6 +38,24 @@ local function GetSCC( vtMachiningDirection)
return nSCC
end
-- Calcolo distanza dalla quale andare a velocità di lavoro ( Start Safety Length)
-------------------------------------------------------------------------------------------------------------
local function GetDrillApprochSafeDistance( FeatureInfo, nToolIndex, b3Raw)
local b3Box = BBox3d( b3Raw)
b3Box:expand( BeamData.COLL_SIC)
local ptStart = Point3d( FeatureInfo.ptDrillCenter)
local DistanceData = {}
DistanceData.vtNFace = Vector3d( FeatureInfo.vtDrillExtrusion)
DistanceData.vtMove = Vector3d( FeatureInfo.vtDrillExtrusion)
DistanceData.dToolLength = TOOLS[nToolIndex].dLength
DistanceData.dToolTotalLength = TOOLS[nToolIndex].dTotalLength
DistanceData.dToolDiameter = TOOLS[nToolIndex].dDiameter
DistanceData.sToolFamily = TOOLS[nToolIndex].sFamily
DistanceData.ptReferencePoint = ptStart + DistanceData.dToolLength * DistanceData.vtNFace
return PreSimulationLib.GetDistanceToRetractToolFromRaw( DistanceData, b3Box)
end
-------------------------------------------------------------------------------------------------------------
local function GetDrillingStrategy( Proc, Part)
local ToolSearchParameters = {}
@@ -51,6 +70,7 @@ local function GetDrillingStrategy( Proc, Part)
ToolSearchParameters.dDiameterTolerance = Strategy.Parameters.dDiameterTolerance
ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sDrillBitList, 'Drilling')
ToolSearchParameters.ptCheckOutStroke = { Proc.FeatureInfo.ptDrillCenter + ( EgtMdbGetGeneralParam( MCH_GP.SAFEZ) * ToolSearchParameters.vtToolDirection)}
ToolSearchParameters.Part = Part
Drilling.ToolInfo = {}
Drilling.ToolInfo = MachiningLib.FindDrill( Proc, ToolSearchParameters)
@@ -61,6 +81,7 @@ local function GetDrillingStrategy( Proc, Part)
Drilling.vtToolDirection = Proc.FeatureInfo.vtDrillExtrusion
Drilling.dStep = TOOLS[Drilling.nToolIndex].dStep
Drilling.nSCC = GetSCC( -Drilling.vtToolDirection)
Drilling.dStartSafetyLength = max( BeamData.COLL_SIC, GetDrillApprochSafeDistance( Proc.FeatureInfo, Drilling.ToolInfo.nToolIndex, Part.b3Raw))
end
-- TODO se utensile 2 che si torverà è il gemello da usare nelle lavorazioni in doppio, allora gestire di conseguenza l'applicazione delle lavorazioni in doppio
@@ -74,7 +95,8 @@ local function GetDrillingStrategy( Proc, Part)
ToolSearchParameters.dDiameterTolerance = Strategy.Parameters.dDiameterTolerance
ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sDrillBitList, 'Drilling')
ToolSearchParameters.ptCheckOutStroke = { Proc.FeatureInfo.ptDrillCenter + ( ( Proc.FeatureInfo.dDrillLen + EgtMdbGetGeneralParam( MCH_GP.SAFEZ)) * ToolSearchParameters.vtToolDirection)}
ToolSearchParameters.Part = Part
Drilling2.ToolInfo = MachiningLib.FindDrill( Proc, ToolSearchParameters)
-- se trovato utensile si settano i parametri comuni
if Drilling2.ToolInfo.nToolIndex then
@@ -84,6 +106,7 @@ local function GetDrillingStrategy( Proc, Part)
Drilling2.vtToolDirection = -Proc.FeatureInfo.vtDrillExtrusion
Drilling2.dStep = TOOLS[Drilling2.nToolIndex].dStep
Drilling2.nSCC = GetSCC( -Drilling2.vtToolDirection)
Drilling2.dStartSafetyLength = max( BeamData.COLL_SIC, GetDrillApprochSafeDistance( Proc.FeatureInfo, Drilling2.ToolInfo.nToolIndex, Part.b3Raw))
end
end
+42 -50
View File
@@ -171,58 +171,50 @@ local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters
Cutting2.nInternalSortingPriority = 2
Cutting2.dResultWeight = 0.3
-- se entrambi i lati lavorati e codolo centrale, si aggiungono in lista senza fare altro
if Cutting1.bIsApplicable and Cutting2.bIsApplicable and not bAllowPerpendicularStrip then
-- se uno dei due lati non è riuscito, si estende il più possibile il lato rimasto
if not Cutting1.bIsApplicable and Cutting2.bIsApplicable then
-- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro
if OtherBottomFace and ( EdgeToMachine.idAdjacentFace == OtherBottomFace.id) then
dStripWidth = TOOLS[Cutting2.nToolIndex].dThickness + 2 * dStripWidth
end
-- se richiesto, si calcola il codolo verticale
if bAllowPerpendicularStrip and FeatureLib.IsMachiningLong( Cutting1.dEdgeLength, Part) then
dDepthToMachine = TOOLS[Cutting2.nToolIndex].dMaxMaterial - 10
else
dDepthToMachine = min( TOOLS[Cutting2.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth)
end
OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine
Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2)
Cutting2.nInternalSortingPriority = 2
Cutting2.dResultWeight = 0.3
table.insert( Cuttings, Cutting2)
elseif not Cutting2.bIsApplicable and Cutting1.bIsApplicable then
-- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro
if OtherBottomFace and ( EdgeToMachine.idAdjacentFace == OtherBottomFace.id) then
dStripWidth = TOOLS[Cutting1.nToolIndex].dThickness + 2 * dStripWidth
end
-- se richiesto, si calcola il codolo verticale
if bAllowPerpendicularStrip and FeatureLib.IsMachiningLong( Cutting2.dEdgeLength, Part) then
dDepthToMachine = TOOLS[Cutting1.nToolIndex].dMaxMaterial - 10
else
dDepthToMachine = min( TOOLS[Cutting1.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth)
end
OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine
Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1)
Cutting1.nInternalSortingPriority = 2
Cutting1.dResultWeight = 0.3
table.insert( Cuttings, Cutting1)
else
table.insert( Cuttings, Cutting1)
table.insert( Cuttings, Cutting2)
else
-- si estende il lato il più possibile
if Cutting1.bIsApplicable then
-- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro
if OtherBottomFace and ( EdgeToMachine.idAdjacentFace == OtherBottomFace.id) then
dStripWidth = TOOLS[Cutting1.nToolIndex].dThickness + 2 * dStripWidth
end
-- se richiesto, si calcola il codolo verticale
if bAllowPerpendicularStrip and FeatureLib.IsMachiningLong( Cutting1.dEdgeLength, Part) then
dDepthToMachine = TOOLS[Cutting1.nToolIndex].dMaxMaterial - 10
-- CASO SPECIALE : se il massimo materiale è più di 3 volte la faccia, si fa lavorazione solo da un lato, l'altro viene annullato
if TOOLS[Cutting1.nToolIndex].dMaxMaterial / 3 > EdgeToMachine.dElevation then
Cutting2.bIsApplicable = false
end
else
dDepthToMachine = min( TOOLS[Cutting1.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth)
end
OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine
Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1)
Cutting1.nInternalSortingPriority = 2
Cutting1.dResultWeight = 0.3
table.insert( Cuttings, Cutting1)
end
-- si estende il lato il più possibile
if Cutting2.bIsApplicable then
-- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro
if OtherBottomFace and ( EdgeToMachine.idAdjacentFace == OtherBottomFace.id) then
dStripWidth = TOOLS[Cutting2.nToolIndex].dThickness + 2 * dStripWidth
end
-- se richiesto, si calcola il codolo verticale
if bAllowPerpendicularStrip and FeatureLib.IsMachiningLong( Cutting1.dEdgeLength, Part) then
dDepthToMachine = TOOLS[Cutting2.nToolIndex].dMaxMaterial - 10
else
dDepthToMachine = min( TOOLS[Cutting2.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth)
end
OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine
Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2)
Cutting2.nInternalSortingPriority = 2
Cutting2.dResultWeight = 0.3
table.insert( Cuttings, Cutting2)
end
end
return Cuttings
+1 -1
View File
@@ -2,5 +2,5 @@
-- Gestione della versione di BeamNT
NAME = 'BeamNT'
VERSION = '3.1h1_DEV1'
VERSION = '3.1g5'
MIN_EXE = '3.1g3'