DataBeam :

- gestite feature blockhaus lavorate con utensile tipo lama di fianco.
This commit is contained in:
Dario Sassi
2020-02-04 10:20:40 +00:00
parent 91ab205dc8
commit 364b76cacc
+315 -218
View File
@@ -1,4 +1,4 @@
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/01/11
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/02/04
-- Gestione calcolo mezzo-legno per Travi
-- 2019/10/08 Agg. gestione OpenPocket.
@@ -34,119 +34,6 @@ function ProcessLapJoint.Identify( Proc)
( Proc.Grp == 4 and Proc.Prc == 39))
end
---------------------------------------------------------------------
-- Verifica se feature di testa
function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
-- verifico se è in testa
if Proc.Box:getMax():getX() < b3Raw:getMax():getX() - dCurrOvmH - BD.MAX_DIST_HTFEA then
return false
end
-- la sua lunghezza non deve superare il massimo e 60% della lunghezza della trave
if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 *b3Raw:getDimX()) then
return false
end
-- se una o due facce ora è sicuramente di testa
if Proc.Fct <= 2 then
return true
end
-- deve avere la normale principale diretta verso la testa
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
end
if vtN:getX() < 0.499 then
return false
elseif Proc.Fct >= 5 then
return true
end
-- deve occupare la maggior parte dell'area
if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then
return true
end
-- non è di testa
return false
end
---------------------------------------------------------------------
-- Verifica se feature di coda
function ProcessLapJoint.IsTailFeature( Proc, b3Raw)
-- verifico se è in coda
if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then
return false
end
-- la sua lunghezza non deve superare il massimo e 60% della lunghezza della trave
if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 * b3Raw:getDimX()) then
return false
end
-- se una o due facce ora è sicuramente di coda
--if Proc.Fct <= 2 then
-- return true
--end
-- deve avere la normale principale diretta verso la coda
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
end
if vtN:getX() > -0.499 then
return false
else
return true
end
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessLapJoint.Classify( Proc)
-- se 1 faccia
if Proc.Fct == 1 then
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
--local bDown = ( vtN:getZ() < BD.NZ_MINA)
--return true, bDown
return true, false
-- se 2 facce
elseif Proc.Fct == 2 then
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
local bSmall = ( ( Proc.Head or Proc.Tail) and Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) or
( not ( Proc.Head or Proc.Tail) and Proc.Box:getDimY() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM)
local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or
( vtN[1]:getZ() < BD.NZ_MINA and ( vtN[2]:getZ() < -0.1 or not bSmall)) or
( vtN[2]:getZ() < BD.NZ_MINA and ( vtN[1]:getZ() < -0.1 or not bSmall))
return true, bDown
-- se più di 2 facce
else
-- recupero la faccia con il maggior numero di adiacenze e minor elevazione
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
if nFacInd < 0 then
return false
end
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
local bDown = ( vtN:getZ() < BD.NZ_MINA)
-- se verso il basso, verifico se utilizzabile seconda faccia
if bDown then
if nFacInd2 and dElev2 < 2 * dElev then
local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
bDown = ( vtN2:getZ() < BD.NZ_MINA)
end
end
return true, bDown
end
end
---------------------------------------------------------------------
local function TestElleShape3( Proc)
@@ -206,6 +93,171 @@ local function TestElleShape4( Proc)
end
end
---------------------------------------------------------------------
local function VerifyIfByBHSideMill( Proc)
local bUseBHSideMill = false
local bHead = true
local sMilling
local dMaxMat = 10
-- verifico se U
local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc))
-- se U e lunghezza non richiede spezzatura
if bIsU and Proc.Box:getDimX() <= BD.LONGCUT_MAXLEN then
-- recupero la lavorazione
sMilling = ML.FindMilling( 'BHSideMill')
if sMilling then
-- recupero i dati dell'utensile
local dToolLength = 0
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat
end
end
-- verifico se la feature è abbastanza vicino a testa/coda da permettere la lavorazione con questo utensile
-- recupero l'ingombro della trave
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
if b3Solid then
local dMinXF = Proc.Box:getMin():getX()
local dMaxXF = Proc.Box:getMax():getX()
local dMinT = b3Solid:getMin():getX()
local dMaxT = b3Solid:getMax():getX()
-- determino se è più vicino alla testa o al bordo
bHead = ( dMaxT - dMinXF) < ( dMaxXF - dMinT)
-- determino se è compatibile con il massimo affondamento dell'utensile
bUseBHSideMill = EgtIf( bHead, (dMaxT - dMinXF), (dMaxXF - dMinT)) < dMaxDepth
end
end
end
return bUseBHSideMill, bHead, sMilling, dMaxMat
end
---------------------------------------------------------------------
-- Verifica se feature di testa
function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
-- verifico se è in testa
if Proc.Box:getMax():getX() < b3Raw:getMax():getX() - dCurrOvmH - BD.MAX_DIST_HTFEA then
return false
end
-- la sua lunghezza non deve superare il massimo e 60% della lunghezza della trave
if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 *b3Raw:getDimX()) then
return false
end
-- se una o due facce ora è sicuramente di testa
if Proc.Fct <= 2 then
return true
end
-- deve avere la normale principale diretta verso la testa
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
end
if vtN:getX() < 0.499 then
return false
elseif Proc.Fct >= 5 then
return true
end
-- deve occupare la maggior parte dell'area
if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then
return true
end
-- non è di testa
return false
end
---------------------------------------------------------------------
-- Verifica se feature di coda
function ProcessLapJoint.IsTailFeature( Proc, b3Raw)
-- se può essere fatto con utensile tipo lama
local bUseBHSideMill, bHead = VerifyIfByBHSideMill( Proc)
if bUseBHSideMill then
return not bHead
end
-- verifico se è in coda
if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then
return false
end
-- la sua lunghezza non deve superare il massimo e 60% della lunghezza della trave
if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 * b3Raw:getDimX()) then
return false
end
-- deve avere la normale principale diretta verso la coda
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
end
if vtN:getX() > -0.499 then
return false
else
return true
end
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessLapJoint.Classify( Proc)
-- se 1 faccia
if Proc.Fct == 1 then
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
--local bDown = ( vtN:getZ() < BD.NZ_MINA)
--return true, bDown
return true, false
-- se 2 facce
elseif Proc.Fct == 2 then
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
local bSmall = ( ( Proc.Head or Proc.Tail) and Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) or
( not ( Proc.Head or Proc.Tail) and Proc.Box:getDimY() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM)
local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or
( vtN[1]:getZ() < BD.NZ_MINA and ( vtN[2]:getZ() < -0.1 or not bSmall)) or
( vtN[2]:getZ() < BD.NZ_MINA and ( vtN[1]:getZ() < -0.1 or not bSmall))
return true, bDown
-- se più di 2 facce
else
-- recupero la faccia con il maggior numero di adiacenze e minor elevazione
local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL)
local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
if not nFacInd or nFacInd < 0 then
return false
end
-- se può essere fatto con utensile tipo lama
local bUseBHSideMill = VerifyIfByBHSideMill( Proc)
if bUseBHSideMill then
return true, false
-- altrimenti controllo se deve essere ruotato con le altre lavorazioni
else
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
local bDown = ( vtN:getZ() < BD.NZ_MINA)
-- se verso il basso, verifico se utilizzabile seconda faccia
if bDown then
if nFacInd2 and dElev2 < 2 * dElev then
local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
bDown = ( vtN2:getZ() < BD.NZ_MINA)
end
end
return true, bDown
end
end
end
---------------------------------------------------------------------
-- Lavorazione con fresa
---------------------------------------------------------------------
@@ -689,6 +741,13 @@ end
local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
-- recupero l'ingombro del grezzo di appartenenza
local b3Raw = EgtGetRawPartBBox( nRawId)
-- recupero l'ingombro della trave
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
if not b3Solid then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
EgtOutLog( sErr)
return false, sErr
end
-- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa
local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
if not nFacInd or nFacInd < 0 then
@@ -698,120 +757,158 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
end
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- se orientata verso il basso, verifico l'alternativa
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
dFacElev, dFacElev2 = dFacElev2, dFacElev
end
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico non sia orientata verso il basso
local bFaceOk = ( vtN:getZ() >= BD.NZ_MINA)
if not bFaceOk then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' LapJoint from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- verifico se U
local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc))
-- eventuali tagli preliminari
do
local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw)
if not bOk then return false, sErr end
end
-- recupero la lavorazione
local sMchFind = 'Pocket'
if Proc.Fct < 3 or bIsU then sMchFind = 'OpenPocket' end
local dDiam = min( dH, dV)
local dCollSic = 2 * BD.COLL_SIC
if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = BD.COLL_SIC end
--EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam))
local sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic)
-- se non trova una svuotatura adatta
if not sPocketing then
-- verifico se due facce o L con una o due facce di terminazione
local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2)
-- provo con contornatura
if bIsL then
return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev)
-- altrimenti provo con la sega a catena o lama
else
local bOk, sErr, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev)
if not bOk and sStat == 'MNF' then
sPocketing = ML.FindPocketing( sMchFind, dDiam)
if not sPocketing then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
else
return bOk, sErr
end
-- se fattibile con fresa BH di fianco
local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc)
if bMakeBySideMill then
-- inserisco la lavorazione di fresatura
local sName = 'BHMill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
end
-- se richiesti antischeggia con lama su U trasversale
if EgtGetInfo( Proc.Id, 'Q06', 'i') == 1 and bIsU and
( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then
-- va eseguito sulle facce diverse dalla principale
for nFacet = 0, 2 do
if nFacet ~= nFacInd then
local bOk, sErr = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
if not bOk then return false, sErr end
end
end
end
-- recupero i dati dell'utensile
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth)
end
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sPocketing)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT)
-- imposto posizione braccio porta testa
if vtN:getY() < GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- se tasca aperta, imposto opportuno attacco
if sMchFind == 'OpenPocket' then
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
end
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
local sWarn
if dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dFacElev)
dFacElev = dMaxDepth
sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
-- imposto elevazione e dichiaro non si generano sfridi per VMill
local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';'
sNotes = sNotes .. 'VMRS=0;'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
-- eseguo
if not EgtApplyMachining( true, false) then
-- provo ad allargare leggermente la tasca
EgtSetMachiningParam( MCH_MP.OFFSR, -0.1)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso del lato faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHead, MCH_MILL_FU.PARAL_LEFT, MCH_MILL_FU.PARAL_RIGHT))
-- calcolo step effettivo ed elevazione
local dVcalc = dV - dMaxMat
local dStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMaxMat
local nStep = ceil( dVcalc / dStep)
dStep = dVcalc / nStep
EgtSetMachiningParam( MCH_MP.STEP, dStep)
-- imposto elevazione e dichiaro non si generano sfridi per VMill
local sNotes = 'MaxElev=' .. EgtNumToString( dVcalc + dStep, 2) .. ';'
sNotes = sNotes .. 'VMRS=0;'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- altrimenti lavoro con svuotatura
else
-- se orientata verso il basso, verifico l'alternativa
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
nFacInd, nFacInd2 = nFacInd2, nFacInd
dFacElev, dFacElev2 = dFacElev2, dFacElev
end
rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico non sia orientata verso il basso
local bFaceOk = ( vtN:getZ() >= BD.NZ_MINA)
if not bFaceOk then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' LapJoint from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- eventuali tagli preliminari
do
local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw)
if not bOk then return false, sErr end
end
-- recupero la lavorazione
local sMchFind = 'Pocket'
if Proc.Fct < 3 or bIsU then sMchFind = 'OpenPocket' end
local dDiam = min( dH, dV)
local dCollSic = 2 * BD.COLL_SIC
if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = BD.COLL_SIC end
--EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam))
local sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic)
-- se non trova una svuotatura adatta
if not sPocketing then
-- verifico se due facce o L con una o due facce di terminazione
local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2)
-- provo con contornatura
if bIsL then
return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev)
-- altrimenti provo con la sega a catena o lama
else
local bOk, sErr, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev)
if not bOk and sStat == 'MNF' then
sPocketing = ML.FindPocketing( sMchFind, dDiam)
if not sPocketing then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
else
return bOk, sErr
end
end
end
-- se richiesti antischeggia con lama su U trasversale
if EgtGetInfo( Proc.Id, 'Q06', 'i') == 1 and bIsU and
( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then
-- va eseguito sulle facce diverse dalla principale
for nFacet = 0, 2 do
if nFacet ~= nFacInd then
local bOk, sErr = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
if not bOk then return false, sErr end
end
end
end
-- recupero i dati dell'utensile
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth)
end
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sPocketing)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT)
-- imposto posizione braccio porta testa
if vtN:getY() < GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- se tasca aperta, imposto opportuno attacco
if sMchFind == 'OpenPocket' then
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
end
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
local sWarn
if dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dFacElev)
dFacElev = dMaxDepth
sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
-- imposto elevazione e dichiaro non si generano sfridi per VMill
local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';'
sNotes = sNotes .. 'VMRS=0;'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
-- eseguo
if not EgtApplyMachining( true, false) then
-- provo ad allargare leggermente la tasca
EgtSetMachiningParam( MCH_MP.OFFSR, -0.1)
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
end
end
return true, sWarn
end