DataBeam :
- gestione completa Fessure Passanti - completata gestione Profili.
This commit is contained in:
+618
-163
@@ -20,6 +20,11 @@ EgtOutLog( ' ProcessLapJoint started', 1)
|
||||
local BD = require( 'BeamData')
|
||||
local ML = require( 'MachiningLib')
|
||||
|
||||
-- variabili assegnazione parametri Q
|
||||
local sForceUseBlade = 'Q01' -- i
|
||||
local sDepthChamferMill = 'Q04' -- d
|
||||
local sPreemptiveChamfer = 'Q05' -- i
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Riconoscimento della feature
|
||||
function ProcessLapJoint.Identify( Proc)
|
||||
@@ -93,6 +98,62 @@ local function TestElleShape4( Proc)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function VerifySawChain( Proc, dMinDim, dMaxDim, vtOrtho)
|
||||
local bUseSawChain = false
|
||||
local sMchFind = 'Sawing'
|
||||
local sSawing = ML.FindSawing(sMchFind)
|
||||
local dMaxMat = 0
|
||||
local dSawCornerRad = 0
|
||||
local dSawThick = 0
|
||||
-- se non trova una lavorazione di sawing esco
|
||||
if not sSawing then
|
||||
return bUseSawChain
|
||||
else
|
||||
-- recupero i dati dell'utensile
|
||||
local dToolLength = 0
|
||||
local dSawWidth = 75
|
||||
if EgtMdbSetCurrMachining( sSawing) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength
|
||||
dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat
|
||||
dSawWidth = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawWidth
|
||||
dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick
|
||||
dSawCornerRad = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) or dSawCornerRad
|
||||
end
|
||||
if dSawThick <= dMinDim and dSawWidth <= dMaxDim then
|
||||
bUseSawChain = true
|
||||
end
|
||||
end
|
||||
end
|
||||
return bUseSawChain, sSawing, dMaxMat, dSawCornerRad, dSawThick
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function VerifyIfPocket( Proc, dDiam, vtOrtho)
|
||||
local bUsePocketing = false
|
||||
local sMchFind = 'Pocket'
|
||||
-- local dCollSic = 2 * BD.COLL_SIC
|
||||
-- if abs( vtOrtho:getX()) > 0.996 or abs( vtOrtho:getY()) > 0.996 or abs( vtOrtho:getZ()) > 0.996 then dCollSic = BD.COLL_SIC end
|
||||
local sPocketing = ML.FindPocketing( sMchFind, dDiam)
|
||||
local dMaxMat = 0
|
||||
-- se non trova una svuotatura adatta
|
||||
if not sPocketing then
|
||||
return bUsePocketing
|
||||
else
|
||||
-- recupero i dati dell'utensile
|
||||
if EgtMdbSetCurrMachining( sPocketing) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat
|
||||
end
|
||||
bUsePocketing = true
|
||||
end
|
||||
end
|
||||
return bUsePocketing, sPocketing, dMaxMat
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function VerifyIfByBHSideMill( Proc)
|
||||
local bUseBHSideMill = false
|
||||
@@ -136,6 +197,60 @@ local function VerifyIfByBHSideMill( Proc)
|
||||
return bUseBHSideMill, bHead, sMilling, dMaxMat
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetTunnelDimension( Proc, nPartId)
|
||||
-- ottengo i versori delle 4 facce e ottengo l'orientamento del tunnel
|
||||
-- recupero il numero di facce
|
||||
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
|
||||
-- recupero l'ingombro della trave
|
||||
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
-- variabili dimensioni fessura e id faccia lunga
|
||||
local dDimMin
|
||||
local dDimMax
|
||||
local nLongIdFace = 0
|
||||
-- ottengo il versore ortogonale
|
||||
local ptN1, vtN1 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
|
||||
local vtOrtho = vtN1 ^ vtN2
|
||||
if vtOrtho:isSmall() then
|
||||
_, vtN2 = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT)
|
||||
vtOrtho = vtN1 ^ vtN2
|
||||
end
|
||||
-- ottengo il boundingBox e prendo le dimensioni lungo la normale (Z locale) che rappresenta la profondità della fessura
|
||||
local frFc = Frame3d( ptN1, vtOrtho) ;
|
||||
local bBoxLoc = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frFc)
|
||||
local dDepth = bBoxLoc:getDimZ()
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- creeo superfice intermedia
|
||||
local nSurfInt = EgtSurfTmPlaneInBBox( nAddGrpId, ptN1, vtOrtho, b3Solid, GDB_ID.ROOT)
|
||||
-- ritaglio la superfici con le facce della fessura
|
||||
for i = 1, nFacCnt do
|
||||
local ptN, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
EgtCutSurfTmPlane( nSurfInt, ptN, -vtN, false, GDB_ID.ROOT)
|
||||
end
|
||||
local _, DimH, DimV = EgtSurfTmFacetMinAreaRectangle( nSurfInt, 0, GDB_ID.ROOT)
|
||||
dDimMin = min( DimH, DimV)
|
||||
dDimMax = max( DimH, DimV)
|
||||
_, DimH, DimV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacCnt-1, GDB_ID.ROOT)
|
||||
-- se faccia pari alla larghezza fessura
|
||||
if abs(DimH - dDimMax) < GEO.EPS_SMALL or abs(DimV - dDimMax) < GEO.EPS_SMALL then
|
||||
nLongIdFace = nFacCnt-1
|
||||
-- altrimenti faccia pari allo spessore fessura
|
||||
else
|
||||
nLongIdFace = nFacCnt-2
|
||||
end
|
||||
if not dDimMax then
|
||||
return dDimMin, dDimMax, dDepth, nil, nil
|
||||
end
|
||||
return dDimMin, dDimMax, dDepth, vtOrtho, nLongIdFace, nSurfInt
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Verifica se feature di testa
|
||||
function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
|
||||
@@ -252,31 +367,51 @@ function ProcessLapJoint.Classify( Proc)
|
||||
return true, bDown
|
||||
-- se più di 2 facce
|
||||
else
|
||||
local bClosedOrthoFaces
|
||||
-- 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
|
||||
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
-- se può essere fatto con utensile tipo lama
|
||||
local bUseBHSideMill, _, _, dMaxMat = VerifyIfByBHSideMill( Proc)
|
||||
if bUseBHSideMill and ( dMaxMat <= dV) 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
|
||||
if nFacInd == -1 then
|
||||
bClosedOrthoFaces = nFacInd2
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
-- se facce formano un tunnel e sono ortogonali
|
||||
if bClosedOrthoFaces then
|
||||
-- ottengo le dimensioni del tunnel
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
EgtErase(nSurfInt)
|
||||
-- verifico se può essere fatto con svuotatura
|
||||
if VerifyIfPocket( Proc, dDimMin, vtOrtho) then
|
||||
return true, false
|
||||
elseif VerifySawChain( Proc, dDimMin, dDimMax, vtOrtho) then
|
||||
return true, false
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
-- se può essere fatto con utensile tipo lama
|
||||
local bUseBHSideMill, _, _, dMaxMat = VerifyIfByBHSideMill( Proc)
|
||||
if bUseBHSideMill and ( dMaxMat <= dV) 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
|
||||
return true, bDown
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -593,7 +728,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev)
|
||||
local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev, bForceUseBlade)
|
||||
-- Recupero le facce adiacenti alla principale
|
||||
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
|
||||
if not vAdj or #vAdj == 0 then
|
||||
@@ -659,6 +794,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac,
|
||||
end
|
||||
end
|
||||
-- Se entrambi gli estremi sono aperti e possibile, lavoro con la lama
|
||||
-- if ( ( bOpenStart and bOpenEnd) or bForceUseBlade) and dElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then
|
||||
if bOpenStart and bOpenEnd and dElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then
|
||||
-- Recupero la lavorazione di lama
|
||||
local sCutting = ML.FindCutting( 'HeadSide')
|
||||
@@ -804,8 +940,44 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
|
||||
return BL.MakeOneFaceBySaw( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function VerifyQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCham, sUseBlade)
|
||||
local nChamfer = 0
|
||||
local bForceUseBlade = false
|
||||
-- verifico che lo smusso sia richiesto
|
||||
local dDepth = EgtGetInfo( Proc.Id, sDephtCham, 'd') or 0
|
||||
if dDepth > 0 then
|
||||
nChamfer = 1
|
||||
end
|
||||
-- verifico se posso fare solo lo smusso
|
||||
if EgtGetInfo( Proc.Id, sOnlyCham, 'i') == 1 then
|
||||
if dDepth > 0 then
|
||||
nChamfer = nChamfer + 1
|
||||
-- altrimenti se non ho l'affondamento esco
|
||||
else
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' no chamfer depth'
|
||||
EgtOutLog( sErr)
|
||||
return -1, dDepth, sErr
|
||||
end
|
||||
end
|
||||
-- verifico se devo usare lama invece della sega-catena
|
||||
if EgtGetInfo( Proc.Id, sUseBlade, 'i') == 1 then
|
||||
bForceUseBlade = true
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' chamfer not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return -1, 0, sErr
|
||||
end
|
||||
|
||||
return nChamfer, dDepth, sMilling, bForceUseBlade
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
|
||||
local sWarn
|
||||
-- recupero l'ingombro del grezzo di appartenenza
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- recupero l'ingombro della trave
|
||||
@@ -815,163 +987,446 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
local bClosedOrthoFaces
|
||||
-- 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
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeMoreFaces could not find reference face'
|
||||
if nFacInd == -1 then
|
||||
bClosedOrthoFaces = nFacInd2
|
||||
else
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeMoreFaces could not find reference face'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- dati della faccia
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
-- verifico se U
|
||||
local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc))
|
||||
-- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia
|
||||
local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc)
|
||||
if bMakeBySideMill and ( dMaxMat <= dV) 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
|
||||
-- verifico se sono presenti i parametri Q per la profondità smusso e
|
||||
-- per eseguire in esclusiva solo lo smusso
|
||||
local nChamfer, dDepthCham, sChamfer, bForceUseBlade = VerifyQParam( Proc, nRawId, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade)
|
||||
-- se non posso lavorare la feature perché condizionata dall'esecuzione del solo chamfer
|
||||
-- genero errore e non faccio nulla
|
||||
if nChamfer < 0 then
|
||||
return false, sChamfer
|
||||
end
|
||||
if bClosedOrthoFaces then -- se tunnel provo a vedere se è possibile lavorarlo di con la svuotatura o con la sega catena
|
||||
-- ottengo le dimensioni del tunnel
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
-- se devo inserire il chamfer
|
||||
if nChamfer > 0 then
|
||||
-- ottengo le curve di contorno libero
|
||||
local nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
if nAuxId1 then
|
||||
local dExtra = 2
|
||||
for i = 1, nNumIdAux do
|
||||
local AuxId = nAuxId1 + i - 1
|
||||
local vtExtr, _, _ = EgtCurveArea( AuxId)
|
||||
local fFrCurve = EgtGetGlobFrame( AuxId)
|
||||
if vtExtr then
|
||||
vtExtr:toGlob( fFrCurve)
|
||||
if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then
|
||||
-- inserisco la lavorazione
|
||||
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchId = EgtAddMachining( sNameCh, sChamfer)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- modifico estrusione percorso
|
||||
EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtExtr:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
-- se non perpendicolare emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : chamfer skipped because not perpendicular to face or from bottom'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
--emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : chamfer skipped because not perpendicular to face'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 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 = 0 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'
|
||||
-- se smusso non è esclusivo
|
||||
if nChamfer < 2 then
|
||||
-- verifico se può essere fatto con svuotatura
|
||||
local bMakePocket, sPocketing, dMaxMat = VerifyIfPocket( Proc, dDimMin, vtOrtho)
|
||||
if bMakePocket then
|
||||
-- gestione svuotatura da un solo lato o anche dal lato opposto (se non verticale)
|
||||
-- estraggo il contorno dalla superfice per evitare i problemi con la svuotatura
|
||||
-- e assegno l'estrusione
|
||||
local nPathInt, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId)
|
||||
EgtModifyCurveExtrusion( nPathInt, vtOrtho, GDB_RT.GLOB)
|
||||
-- variabili per parametri lavorazione
|
||||
local dMachDepth
|
||||
local dElev = 0
|
||||
local bDoubleSide
|
||||
-- se possibile svuotare completamente da una sola parte
|
||||
if dMaxMat > ( dDepth + 2) then
|
||||
dMachDepth = (dDepth / 2) + 2
|
||||
dElev = dDepth
|
||||
else
|
||||
-- se direzione verso la verticale setto max affondamento possibile ed
|
||||
-- emetto messaggio di warning perché non lavorabile interamente
|
||||
if abs(vtOrtho:getZ()) >= 0.707 then
|
||||
dMachDepth = dMaxMat - (dDepth / 2)
|
||||
dElev = dMaxMat
|
||||
sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
|
||||
EgtOutLog( sWarn)
|
||||
-- altrimenti setto il flag per fare la svuotatura da due parti
|
||||
else
|
||||
if dMaxMat > (dDepth / 2) then
|
||||
dMachDepth = 1
|
||||
dElev = (dDepth / 2) + 1
|
||||
else
|
||||
dMachDepth = dMaxMat - (dDepth / 2)
|
||||
dElev = dMaxMat
|
||||
end
|
||||
bDoubleSide = true
|
||||
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( {{ nPathInt, -1}})
|
||||
-- verifico se devo invertire direzione utensile (in caso di direzione verso la verticale)
|
||||
local bInvertMach
|
||||
if vtOrtho:getZ() < BD.NZ_MINA and abs(vtOrtho:getZ()) >= 0.707 then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
bInvertMach = true
|
||||
-- altrimenti se da fare in una sola volta e direzionato verso Y+ lo inverto per lavorarlo davanti
|
||||
elseif not bDoubleSide and vtOrtho:getY() > GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
bInvertMach = true
|
||||
end
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtOrtho:getY() < GEO.EPS_SMALL then
|
||||
if bInvertMach then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
end
|
||||
else
|
||||
if bInvertMach then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
end
|
||||
-- inverto il percorso di lavorazione per lavorare sinistro
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- imposto affondamento
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMachDepth)
|
||||
-- imposto elevazione e dichiaro non si generano sfridi per VMill
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 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
|
||||
-- se posso applicare la svuotatura sul lato opposto
|
||||
if bDoubleSide then
|
||||
-- se anche lavorando dal lato opposto non riesco a svuotare completamente la fessura
|
||||
-- setto i parametri affondamento ed emetto warning
|
||||
if dMaxMat*2 < dDepth then
|
||||
dMachDepth = dMaxMat - (dDepth / 2)
|
||||
dElev = dMaxMat
|
||||
sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
|
||||
EgtOutLog( sWarn)
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = 'PockOppo_' .. ( 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
|
||||
else
|
||||
return bOk, sErr
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ nPathInt, -1}})
|
||||
-- imposto direzione utensile opposta
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtOrtho:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
end
|
||||
-- inverto il percorso di lavorazione per lavorare sinistro
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- imposo affondamento
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMachDepth)
|
||||
-- imposto elevazione e dichiaro non si generano sfridi per VMill
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 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
|
||||
-- altrimenti provo con la sega-catena
|
||||
else
|
||||
local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifySawChain( Proc, dDimMin, dDimMax, vtOrtho)
|
||||
if bMakeChainSaw then
|
||||
-- Verifico se necessarie più passate
|
||||
local nStep = ceil( ( dDimMin - 10 * GEO.EPS_SMALL) / dSawThick)
|
||||
local dStep = 0
|
||||
if nStep > 1 then
|
||||
dStep = ( dDimMin - dSawThick) / ( nStep - 1)
|
||||
end
|
||||
for i = 1, nStep do
|
||||
-- inserisco la lavorazione di sawing
|
||||
local sName = 'Csaw_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchFId = EgtAddMachining( sName, sSawing)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sSawing
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, nLundIdFace}})
|
||||
-- imposto uso del lato faccia
|
||||
-- al momento, dato che la fessura è passante da parte a parte, gestisco solo la lavorazione
|
||||
-- dall'alto e di fronte (da dietro è disabilitata perchè ho exracorsa con la FAST).
|
||||
-- Questa feature non è applicata su facce di testa e quindi non controllo l'entrata in X
|
||||
if abs(vtOrtho:getZ()) >= 0.707 then
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
|
||||
--elseif abs(vtOrtho:getZ()) < 0.707 and abs(vtOrtho:getY()) > 0.707 then
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK)
|
||||
--elseif abs(vtOrtho:getZ()) <= 0.707 and vtOrtho:getY() < -0.707 then
|
||||
-- EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_FRONT)
|
||||
--elseif abs(vtOrtho:getZ()) < 0.707 and vtOrtho:getX() > 0.707 then
|
||||
-- EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_LEFT)
|
||||
--else
|
||||
-- EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_RIGHT)
|
||||
end
|
||||
-- imposto offset radiale
|
||||
local dOffs = ( i - 1) * dStep
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dOffs)
|
||||
-- se possibile aumento l'affondamento pari al raggio corner + 1
|
||||
if dMaxMat > (dDepth + dSawCornerRad + 1) then
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, (dDepth + dSawCornerRad + 1))
|
||||
-- se massimo affondamento utensile inferiore fessura, setto affondamento ed emetto warning
|
||||
elseif dMaxMat < dDepth then
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat)
|
||||
sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
|
||||
EgtOutLog( sWarn)
|
||||
end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
elseif EgtIsMachiningEmpty() then
|
||||
_, sWarn = EgtGetMachMgrWarning( 0)
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sWarn
|
||||
end
|
||||
end
|
||||
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)
|
||||
else
|
||||
-- dati della faccia
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
-- verifico se U
|
||||
local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc))
|
||||
-- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia
|
||||
local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc)
|
||||
if bMakeBySideMill and ( dMaxMat <= dV) then
|
||||
-- se smusso non è esclusivo
|
||||
-- if nChamfer < 2 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
|
||||
-- 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
|
||||
-- end
|
||||
-- altrimenti lavoro con svuotatura
|
||||
else
|
||||
-- se smusso non è esclusivo
|
||||
-- if nChamfer < 2 then
|
||||
-- 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
|
||||
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
|
||||
-- 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 = 0 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, bForceUseBlade)
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user