- in WallLib -> GetProcessDistanceToNearestParts piccole correzioni al calcolo del solido della parte

- in LapJoint -> MakeByPocketing migliorata la scelta utensile e la forzatura tasca chiusa nel caso di parti vicine
This commit is contained in:
luca.mazzoleni
2023-08-29 13:12:34 +02:00
parent 924313a0ea
commit afb33aa7c6
2 changed files with 114 additions and 56 deletions
+101 -45
View File
@@ -1362,8 +1362,10 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId)
b3ProcExtended:Add( ptMax)
local nPartId = EgtGetFirstPartInRawPart( nRawId)
while nPartId do
local b3Part = EgtGetBBoxGlob( nPartId or GDB_ID.NULL, GDB_BB.STANDARD)
if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Part) then
local nBoxSolidId = EgtGetFirstNameInGroup( nPartId, 'Box')
local b3Solid = EgtGetBBoxGlob( nBoxSolidId or GDB_ID.NULL, GDB_BB.STANDARD)
b3Solid:expand( - 10 * GEO.EPS_SMALL)
if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Solid) then
bIsMachiningDamagingOtherParts = true
end
nPartId = EgtGetNextPartInRawPart( nPartId)
@@ -2220,6 +2222,97 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
return true, sWarn
end
---------------------------------------------------------------------
local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
local dStartDiameter = dMaxDiameter
if Proc.AffectedFaces.Front then
dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Front)
end
if Proc.AffectedFaces.Back then
dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Back)
end
if Proc.AffectedFaces.Left then
dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Left)
end
if Proc.AffectedFaces.Right then
dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Right)
end
local bForceClosedPocket = false
-- recupero la lavorazione
local bUseDElevToFindPocketing = true
local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev)
-- se tasca troppo profonda cerco senza elevazione e limiterò la profondità
if not sPocketing then
bUseDElevToFindPocketing = false
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter)
end
local dMillDiam = 20
local dMaxDepth = 0
local dThDiam = 100
local sTuuid
-- se lavorazione trovata verifico eventuale doppio, raccolgo i dati utensile e verifico collisioni dell'utensile con altre parti
if sPocketing then
-- se doppio cerco una lavorazione adatta
if Proc.Double and Proc.Double == 2 then
local sPocketingBackup = sPocketing
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1')
if not IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
end
end
-- recupero diametro utensile
if EgtMdbSetCurrMachining( sPocketing) then
sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
end
end
-- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa
if WD.AVOID_DAMAGING_OTHER_PARTS then
if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or
Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then
bForceClosedPocket = true
end
end
-- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa
else
bForceClosedPocket = true
end
-- se tasca chiusa cerco lavorazione con diametro massimo pari a dimensione tasca e riverifico per eventuale doppio
if bForceClosedPocket then
dMaxDiameter = min( dH, dV)
bUseDElevToFindPocketing = true
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev)
if not sPocketing then
bUseDElevToFindPocketing = false
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter)
end
-- se doppio cerco una lavorazione adatta
if Proc.Double and Proc.Double == 2 then
local sPocketingBackup = sPocketing
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1')
if not IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
end
end
end
-- recupero dati utensile
if EgtMdbSetCurrMachining( sPocketing) then
sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) or dMaxDepth
dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam
end
end
return sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam
end
---------------------------------------------------------------------
local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
-- dati della faccia
@@ -2260,51 +2353,14 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
elseif Proc.Fct >= 4 then
dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000)
end
-- recupero la lavorazione
local bUseDElevToFindPocketing = true
local sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev)
local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV)
if not sPocketing then
bUseDElevToFindPocketing = false
sPocketing = WM.FindPocketing( 'Pocket', dDiam)
if not sPocketing then
local sErr = 'Error : pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
end
if Proc.Double and Proc.Double == 2 then
local sPocketingBackup = sPocketing
sPocketing = WM.FindPocketing( 'Pocket', dDiam, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1')
if not IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
end
end
-- recupero i dati dell'utensile
local dMillDiam = 20
local dMaxDepth = 0
local dThDiam = 100
local sTuuid
if EgtMdbSetCurrMachining( sPocketing) then
sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) or dMaxDepth
dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam
end
end
-- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa
local bForceClosedPocket = false
if WD.AVOID_DAMAGING_OTHER_PARTS then
if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) then
bForceClosedPocket = true
end
if Proc.Double and Proc.Double > 0 then
if IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then
bForceClosedPocket = true
end
end
local sErr = 'Error : pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = WM.AddMachining( Proc, sName, sPocketing)