- varie modifiche, principalmente a MachiningLib e LapJoint, che migliorano il funzionamento delle tasche, anche in doppio.

This commit is contained in:
luca.mazzoleni
2023-11-09 18:17:17 +01:00
parent f9bb10bf6e
commit a84fb0608f
4 changed files with 104 additions and 68 deletions
+92 -63
View File
@@ -32,7 +32,10 @@
-- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata.
-- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa.
-- 2023/10/31 In VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa.
-- 2023/11/06 In VerifyPocket controllo massimo diametro in base a distanza pezzo più vicino demandato a FindPocketing.
-- 2023/11/07 In MakeByPocketing, se tasca che guarda davanti, aggiunta possibilità di attaccare fuori dal grezzo fino ad uno spessore di 75 mm.
-- In MakeByPocketing calcolo del massimo diametro utensile spostato in VerifyPocketing.
-- In MakeByPocketing il doppio viene ora disattivato se una tasca deve essere forzata chiusa e l'altra no.
-- Tabella per definizione modulo
local WPL = {}
@@ -1290,7 +1293,7 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId)
local ptMin = b3ProcExtended:getMin()
local ptMax = b3ProcExtended:getMax()
-- estensione aggiunta ai box
local dBoxExtensionLength = dMillDiameter / 2 + 10
local dBoxExtensionLength = dMillDiameter / 2 + 5
-- check box verso X-
if Proc.AffectedFaces.Left then
local vtMove = Vector3d( -dBoxExtensionLength, 0, 0)
@@ -2183,30 +2186,76 @@ end
---------------------------------------------------------------------
-- trova la migliore lavorazione tasca in base a diametro utensile, elevazione, doppio e eventuale interferenza di parti vicine
-- se necessario forza la tasca a chiusa
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 function VerifyPocket( Proc, nFacet, dElev, nRawId)
local bForceClosedPocket = false
local bExcludeNoTipFeed = Proc.Topology == 'Pocket'
local b3Raw = EgtGetRawPartBBox( nRawId)
-- verifico se la feature è sul bordo (non ci sono altri pezzi davanti alla tasca). Se è sul bordo, l'utensile potrà attaccare da fuori.
local bIsFeatureOnEdge = ( Proc.Topology == 'Groove' and Proc.Fct == 4 and Proc.DistanceToNearestParts.Front > b3Raw:getDimY())
-- trovo il massimo diametro utensile ammissibile per la tasca
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
local dStartDiameter = min( dH, dV)
local dMaxDiameter = dStartDiameter
-- se una sola faccia posso usare un utensile più grande della faccia
if Proc.Fct == 1 then
dMaxDiameter = 2 * dMaxDiameter
end
-- se forma ad L posso usare un utensile più grande della faccia
local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2)
if bIsL then
dMaxDiameter = 2 * dMaxDiameter
end
-- se forma ad U riduco il diametro se necessario
local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct))
if bIsU then
-- prendo la linea di base
local dMiddleFacetLength = 0
if abs( dElev - dH) < 1 and abs( dElev - dV) > 1 then
dMiddleFacetLength = dV
elseif abs( dElev - dV) < 1 and abs( dElev - dH) > 1 then
dMiddleFacetLength = dH
end
if dMiddleFacetLength > dMaxDiameter then
dMaxDiameter = min( 2 * dMaxDiameter, dMiddleFacetLength)
end
end
-- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile
if Proc.Fct == 3 and bIsL then
dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000)
elseif Proc.Fct >= 4 then
dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000)
end
-- verifico la distanza minima dalle parti vicine e nel caso il FindPocketing limiterà il diametro massimo dell'utensile
local dDistanceToNearestPart = GEO.INFINITO
if Proc.AffectedFaces.Front then
dDistanceToNearestPart = Proc.DistanceToNearestParts.Front
end
if Proc.AffectedFaces.Back then
dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Back)
end
if Proc.AffectedFaces.Left then
dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Left)
end
if Proc.AffectedFaces.Right then
dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Right)
end
-- se la distanza è inferiore ad un valore minimo forzo la tasca chiusa per evitare che la ricerca utensile fallisca
local dMinToolDiameter = 25
if dDistanceToNearestPart < dMinToolDiameter / 2 - 10 * GEO.EPS_SMALL then
bForceClosedPocket = true
dDistanceToNearestPart = dMaxDiameter
end
local bExcludeNoTipFeed = ( Proc.Topology == 'Pocket')
-- recupero la lavorazione
local bUseDElevToFindPocketing = true
local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed)
local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart)
-- se tasca troppo profonda cerco senza elevazione e limiterò la profondità
if not sPocketing then
bUseDElevToFindPocketing = false
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed)
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart)
end
local dMillDiam = 20
local dMaxDepth = 0
@@ -2217,7 +2266,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
-- 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', true)
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart)
if not WM.IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
@@ -2230,11 +2279,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
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 IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or
Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then
-- verifico se la lavorazione (o il suo eventuale mirror) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa
local bIsMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId)
if bIsMachiningDamagingOtherParts then
bForceClosedPocket = true
end
-- disattivo il doppio se devo forzare una tasca chiusa ma l'altra no
if Proc.Double and Proc.Double > 0 then
local bIsMirrorMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId)
if bIsMachiningDamagingOtherParts ~= bIsMirrorMachiningDamagingOtherParts then
Proc.Double = 0
end
end
-- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa
else
bForceClosedPocket = true
@@ -2242,17 +2298,17 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
-- se tasca chiusa cerco lavorazione con diametro massimo pari a dimensione tasca e riverifico per eventuale doppio
if bForceClosedPocket then
dMaxDiameter = min( dH, dV)
dMaxDiameter = dStartDiameter
bUseDElevToFindPocketing = true
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed)
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart)
if not sPocketing then
bUseDElevToFindPocketing = false
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed)
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart)
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', true)
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart)
if not WM.IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
@@ -2270,50 +2326,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
end
end
return sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam
return sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam
end
---------------------------------------------------------------------
local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
local dDiam = min( dH, dV)
-- gruppo ausiliario
local nAddGrpId = WL.GetAddGroup( Proc.PartId)
local nNewProc, nNumFacet = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet)
-- se una sola faccia
if Proc.Fct == 1 then
dDiam = 2 * dDiam
end
-- se forma ad L
local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2)
if bIsL then
dDiam = 2 * dDiam
end
-- se forma ad U
local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct))
if bIsU then
local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
-- prendo la linea di base
local dMiddleFacetLength = 0
if abs( dElev - dH2) < 1 and abs( dElev - dV2) > 1 then
dMiddleFacetLength = dV2
elseif abs( dElev - dV2) < 1 and abs( dElev - dH2) > 1 then
dMiddleFacetLength = dH2
end
if dMiddleFacetLength > dDiam then
dDiam = min( 2 * dDiam, dMiddleFacetLength)
end
end
-- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile
if Proc.Fct == 3 and bIsL then
dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000)
elseif Proc.Fct >= 4 then
dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000)
end
local nNewProc = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet)
-- cerco lavorazione adatta e recupero i dati utensile
local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV)
local sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, nFacet, dElev, nRawId)
if not sPocketing then
local sErr = 'Error : pocketing not found in library'
EgtOutLog( sErr)
@@ -2366,6 +2390,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
end
-- setto eventuale nota per forzare tasca chiusa
if bForceClosedPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 0) end
-- setto eventuale nota per forzare attacco esterno, fino ad un certo spessore del grezzo
local dMaxRawThicknessToStartOut = 75
if bIsFeatureOnEdge and ( not Proc.Double or Proc.Double == 0) then sUserNotes = EgtSetValInNotes( sUserNotes, 'OpenMinSafe', dMaxRawThicknessToStartOut) end
-- scrivo le note della lavorazione
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
-- eseguo
@@ -2374,7 +2401,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- verifica parametro Q per pulitura spigoli
local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct))
if bCheckQPar and not ( bIsU and AreSameOrOppositeVectorApprox( vtN, Z_AX())) then
-- lettura parametri (probabile/i parametro/i Q)
local nConeCut = EvaluateQParam( Proc)
@@ -2382,7 +2411,7 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar)
local vFace, dMaxWidth = GetFacesData( nNewProc, false, false, dMillDiam, dMaxDepth, (dMillDiam/2), nAddGrpId, Proc.PartId)
-- se abilitata la lavorazione corner con stop macchina
if nConeCut == 1 then
local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw,
local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw,
dMillDiam, nAddGrpId, dMaxWidth, nNewProc, dDepth)
if not bMcok then return bMcok, sMcErr end
elseif nConeCut == 2 then