DataBeam :

- nuova gestione scanalature longitudinali con lavorazione SideMillAsBlade e SideMillAsBlade_H2.
This commit is contained in:
DarioS
2021-09-22 09:44:11 +02:00
parent ea79bddc58
commit 06d29cd37a
+258 -8
View File
@@ -21,6 +21,8 @@
-- 2021/07/02 Migliorie e correzioni su svuotature e pulitura spigoli.
-- 2021/07/15 Aggiunti antischeggia con fresa.
-- 2021/09/08 Aggiunta gestione parametro Q04 per i tagli di lama lungo facce lunghe (con o senza facce di chiusura)
-- 2021/09/21 Aggiunta lavorazione/opzione "lamello" con le feature 16, 30, 32, 39,
-- che si attiva abilitando il check al tipo milling: SideMillAsBlade (SideMillAsBlade_2)
-- Tabella per definizione modulo
local ProcessLapJoint = {}
@@ -162,13 +164,23 @@ local function EvaluateQParam( Proc)
end
---------------------------------------------------------------------
local function TestElleShape3( Proc)
local function TestElleShape3( Proc, bNotProc)
-- se non passat il Proc vero e proprio
local nNumFacet
local nProcId
if bNotProc then
nProcId = Proc
nNumFacet = EgtSurfTmFacetCount( nProcId)
else
nProcId = Proc.Id
nNumFacet = Proc.Fct
end
-- valida solo nel caso di tre facce
if Proc.Fct ~= 3 then return false end
if nNumFacet ~= 3 then return false end
-- determino se L con una faccia terminale o U con tre facce
local bIsL = true
for i = 1, 3 do
local vFacAdj = EgtSurfTmFacetAdjacencies( Proc.Id, i - 1)[1]
local vFacAdj = EgtSurfTmFacetAdjacencies( nProcId, i - 1)[1]
-- le conto
local nCount = 0
for j = 1, #vFacAdj do
@@ -2525,12 +2537,161 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI
return 0
end
---------------------------------------------------------------------
local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd,
rfFac, dH, dV, dElev, bForceUseBlade,
nBottomFace, nAddGrpId, b3Solid, dSawMaxDepth, sMillingOnSide,
dSawDiam, dSawThick)
local bOrthoFaces
local sWarn
-- ingombro del grezzo
local b3Raw = EgtGetRawPartBBox( nRawId)
-- ottengo la distanza tra la fine del pezzo e il pezzo successivo
local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5.
-- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa
local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId, true)
if not nFacInd1 or nFacInd1 < 0 then
if nFacInd1 == -1 then
bOrthoFaces = nFacInd2
else
local sErr = 'Error : MakeByMillAsSaw could not find reference face'
EgtOutLog( sErr)
return false, sErr
end
end
if bOrthoFaces then
-- ottengo le dimensioni del tunnel
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
end
-- Recupero le facce adiacenti alla principale
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
if not vAdj or #vAdj == 0 then
local sErr = 'Error : main face without adjacencies'
EgtOutLog( sErr)
return false, sErr
end
EgtOutLog( 'Adjac=' .. table.concat( vAdj, ','), 3)
-- Cerco una faccia adiacente alla principale sul lato più lungo
local nFacAdj
local dMaxLen = 0
for i = 1, #vAdj do
if vAdj[i] >= 0 then
local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT)
local dLen = dist( ptP1, ptP2)
if dLen > dMaxLen then
nFacAdj = vAdj[i]
dMaxLen = dLen
EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3)
end
end
end
if not nFacAdj then
local sErr = 'Error : long adjacent face not found'
EgtOutLog( sErr)
return false, sErr
end
-- Riordino le dimensioni per avere dH come lato lungo e dV come perpendicolare
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacAdj, GDB_ID.ROOT)
if abs( vtN * rfFac:getVersX()) > abs( vtN * rfFac:getVersY()) then
dH, dV = dV, dH
end
-- Determino se estremi aperti o chiusi
local bOpenStart = false
local bOpenEnd = false
local vtNS, vtNE
-- se non ho la faccia di fondo ( che comporta essere una fessura) verifico se ho lati aperti
if not nBottomFace then
local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1]
EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,'), 3)
for j = 1, #vAdj2 do
if vAdj2[j] == nFacInd then
-- Se non esiste faccia adiacente a lato precedente -> inizio aperto
local i = EgtIf( j > 1, j - 1, #vAdj2)
while vAdj2[i] == nFacInd do
i = EgtIf( i > 1, i - 1, #vAdj2)
end
bOpenStart = ( vAdj2[i] < 0)
-- se è chiusa acquisisco vettore faccia tappo
if not bOpenStart and vAdj2[i] >= 0 then
_, vtNS = EgtSurfTmFacetCenter( Proc.Id, vAdj2[i], GDB_ID.ROOT)
end
-- Se non esiste faccia adiacente a lato successivo -> fine aperto
local k = EgtIf( j < #vAdj2, j + 1, 1)
while vAdj2[k] == nFacInd do
k = EgtIf( k < #vAdj2, k + 1, 1)
end
bOpenEnd = ( vAdj2[k] < 0)
-- se è chiusa acquisisco vettore faccia tappo
if not bOpenEnd and vAdj2[k] >= 0 then
_, vtNE = EgtSurfTmFacetCenter( Proc.Id, vAdj2[k], GDB_ID.ROOT)
end
end
end
end
-- Se possibile, lavoro con la lama
if bForceUseBlade then
-- Recupero la lavorazione di lama
local sCutting = sMillingOnSide
-- Calcolo uso faccia
local nFaceUse = BL.GetNearestOrthoOpposite( rfFac:getVersZ())
local dStartDist = -1
local dEndDist = -1
-- calcolo eventuali arretramenti lama
if not bOpenStart then
local dRadius = dSawDiam / 2
local dCat1 = dRadius - dElev
dStartDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
end
if not bOpenEnd then
if not bOpenStart then
dEndDist = dStartDist
else
local dRadius = dSawDiam / 2
local dCat1 = dRadius - dElev
dEndDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
end
end
-- Eseguo i tagli
local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick)
local dStep = 0
if nStep > 1 then
dStep = ( dV - dSawThick) / ( nStep - 1)
end
for i = 1, nStep do
local dOffs = ( i - 1) * dStep
local bOk, sErr, nMchId = BL.MakeOneFaceBySaw( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, dStartDist, dEndDist, nil, b3Raw)
if not bOk then return bOk, sErr end
-- setto l'elevazione
local sNotes = 'MaxElev=' .. EgtNumToString( 0, 1) .. ';'
-- applico elevazione
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
-- tolgo eventuale step
EgtSetMachiningParam( MCH_MP.STEP, 0)
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
-- in base all'elevazione calcolo l'impronta della lama
local dUsedBladeLen = sqrt( ((dSawDiam / 2)*(dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev)))
-- controllo direzione taglio e se il minimo della feature sborda in coda
if abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then
-- do avviso che la lama può sbordare nel pezzo successivo
sWarn = 'Warning on mill side as blade : Cut machining can damage next piece'
EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
end
end
return true, sWarn
end
---------------------------------------------------------------------
local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd,
rfFac, dH, dV, dElev, bForceUseBlade,
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace,
bOrthoFacesMaster, nBottomFace, nChamfer, nAddGrpId, b3Solid,
dDepthCham, bIs3Faces)
dDepthCham, nSurfInt, bIs3Faces)
local bOrthoFaces
local sWarn
-- ingombro del grezzo
@@ -4571,16 +4732,95 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
if bMillDown then
sMchFind = sMchFind ..'_H2'
end
-- 2021.09.16 Richiesta di Fabio Squaratti per lavorazione "Lamello":
-- se ho attiva questo tipo di lavorazione (delle fresature) e una di queste feature: L016, L030, L032, L039
-- verifico se sono compatibili con questa lavorazione forma a U e larga più dell'altezza tagliente e profondità compatibile con
local bSpecialMillOnSide
local dThickMillOnSide = 0
local sMillingOnSide
local dToolDiamOnSide = 0
local dMaxDepthOnSide = 0
if ( Proc.Prc == 16 or Proc.Prc == 30 or Proc.Prc == 32 or Proc.Prc == 39) then
-- verifico se ho una gola con 3 facce ed eventualmente delle facce terminali:
-- faccio una copia della superfice e elimino le facce che hanno dimensione X < 1 e le facce risultanti devono essere una U
local nTestId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL
if nTestId then
local bNewIsU
local bExit
local nFaces = EgtSurfTmFacetCount( nTestId)
while not bExit and nFaces >= 3 do
local bDeleteFace
nInt = 0
while not bDeleteFace and nInt < nFaces do
nInt = nInt + 1
local b3Facet = EgtSurfTmGetFacetBBoxGlob( nTestId, nInt-1, GDB_BB.STANDARD)
-- se dimensione faccia sulla X
if b3Facet:getDimX() < 1 then
EgtSurfTmRemoveFacet( nTestId, nInt-1)
bDeleteFace = true
end
end
nFaces = EgtSurfTmFacetCount( nTestId)
-- se non ho cancellato una faccia faccio il test per forma ad U
if not bDeleteFace then
-- ottengo il numero di facce rimanenti
bNewIsU = ( nFaces == 3 and not TestElleShape3( nTestId, true))
bExit = true
end
end
-- cancello la copia del percorso
EgtErase( nTestId)
if bNewIsU then
-- recupero la lavorazione
-- if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then
if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD then
sMillingOnSide = ML.FindMilling( 'SideMillAsBlade_H2')
else
sMillingOnSide = ML.FindMilling( 'SideMillAsBlade')
end
if not sMillingOnSide then
local sErr = 'Error : MillOnSideAsBlade (cutting) not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dToolLength = 0
local sUserNote
if EgtMdbSetCurrMachining( sMillingOnSide) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength
dToolDiamOnSide = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamOnSide
dThickMillOnSide = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dThickMillOnSide
dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide
end
end
-- 2021.09.17 Su conferma di Fabio Squaratti, se la gola è più streta dell'utensile o la profondità della gole è maggiore
-- del valore parametro SIDEDEPTH (preso dalle note utente dell'utensile) allora si prosegue come se non fosse abilitata
-- questo tipo di lavorazione SideMillAsBlade
if dDiam >= dThickMillOnSide and dFacElev < dMaxDepthOnSide + 10 * GEO.EPS_SMALL then
bSpecialMillOnSide = true
-- disabilito eventulae svuotatura
sPocketing = nil
end
end
end
end
-- se feature 16 e forzata lama e forma ad U, annulla la svuotatura
if Proc.Prc == 16 and bForceUseBlade and Proc.Fct == 3 and bIsU then
sPocketing = nil
end
-- leggo parametro Q
local nQAntisplintResult = EgtGetInfo( Proc.Id, Q_ANTISPLINT_TYPE, 'i') or 0
-- se lavorazione fresa come lama disabilito eveentuale antischegggia
if bSpecialMillOnSide then nQAntisplintResult = 0 end
-- se non trova una svuotatura adatta
if not sPocketing then
-- se forma a L provo con contornatura
if bIsL then
if bIsL and not bSpecialMillOnSide then
-- se smusso non è esclusivo
if nChamfer < 2 then
return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, dCollSic)
@@ -4588,7 +4828,17 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
-- altrimenti, in base alla forma, provo con svuotature di fianco o con la sega a catena o lama
else
local bTryWithBlades = true
local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces
local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nSurfInt
if bSpecialMillOnSide then
-- eseguo
bOk, sWarn = MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd,
rfFac, dH, dV, dFacElev, bSpecialMillOnSide,
nBottomFace, nAddGrpId, b3Solid, dMaxDepthOnSide, sMillingOnSide,
dToolDiamOnSide, dThickMillOnSide)
if bOk then
return true, sWarn
end
end
-- se feature 16 o 17 e se forzata lama provo prima con questa e poi con la fresa
if ( Proc.Prc == 16 or Proc.Prc == 17) and bForceUseBlade then
-- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame
@@ -4606,7 +4856,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
rfFac, dH, dV, dFacElev, bForceUseBlade,
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace,
bOrthoFaces, nBottomFace, nChamfer, nAddGrpId, b3Solid,
dDepthCham, true)
dDepthCham, nSurfInt, true)
if not bOk then
-- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e
-- se non è possibile allora provo in seguito con lama o segacatena
@@ -4755,7 +5005,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
rfFac, dH, dV, dFacElev, bForceUseBlade,
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace,
bOrthoFaces, nBottomFace, nChamfer, nAddGrpId, b3Solid,
dDepthCham)
dDepthCham, nSurfInt)
if not bOk and sStat == 'MNF' then
sPocketing = ML.FindPocketing( sMchFind, dDiam)
if not sPocketing then