- Split funzione "MakeMoreFaces";

- Nuova funzione "MakeSpecialThreeFaces" con controllo ortogonalità (non OK)
This commit is contained in:
luca.bacis
2021-12-17 12:08:29 +01:00
parent 4757b1596b
commit 409f62de52
2 changed files with 330 additions and 209 deletions
+329 -208
View File
@@ -1086,6 +1086,10 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV
EgtOutLog( sErr)
return false, sErr
end
EgtOutLog( '*** ProcID=' .. tostring( Proc.Id))
EgtOutLog( '*** Name=' .. EgtGetName( Proc.Id))
EgtOutLog( '*** nFacInd=' .. tostring( nFacInd))
EgtOutLog( '*** nFacAdj=' .. tostring( nFacAdj))
-- Determino se estremi aperti o chiusi e faccia adiacente da aggiungere alla lavorazione
local bOpenStart = false
local bOpenEnd = false
@@ -1152,6 +1156,12 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV
local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ())
-- inserisco la lavorazione di fresatura
local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
-- <LB> --
sName = sName .. '_F' .. tostring(nFacAdj)
EgtOutLog( '*** Milling Face=' .. tostring( nFacAdj))
-- <LB> --
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
@@ -4336,6 +4346,295 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw,
return true, sMyWarn
end
---------------------------------------------------------------------
local function ShowFacesNumber( SurfId)
local nFacCnt = EgtSurfTmFacetCount( SurfId)
for i = 1, nFacCnt do
local fcIdx = i - 1
local pCnt, vtN = EgtSurfTmFacetCenter( SurfId, fcIdx, GDB_ID.ROOT)
local vtN2 = EgtSurfTmFacetNormVersor( SurfId, fcIdx, GDB_ID.ROOT)
local rFrame, _, _ = EgtSurfTmFacetMinAreaRectangle( SurfId, fcIdx)
rFrame:toGlob(EgtGetGlobFrame(SurfId))
local idGrp = EgtGroup( GDB_ID.ROOT, rFrame, GDB_RT.GLOB)
EgtFrame( GDB_ID.ROOT, rFrame, GDB_ID.GLOB)
local idTxt = EgtTextEx( idGrp, {-5, -5, 1}, 0, tostring( fcIdx), 'Arial', 'S', 10)
EgtSetName( idTxt, 'Txt_Surf' .. tostring( SurfId) .. '_Face' .. tostring( fcIdx))
EgtRelocateGlob( idTxt, GDB_ID.ROOT)
EgtErase( idGrp)
end
end
---------------------------------------------------------------------
local function MakeBySideMill( Proc)
local dH, dV
-- se smusso non è esclusivo
if Proc.Fct > 1 then
-- recupero la larghezza della faccia perpendicolarmente alle altre 2
local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT)
local vtX = vtN2 ^ vtN
local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2)
local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef)
if b3Ref then
dV = b3Ref:getDimY()
dH = b3Ref:getDimX()
end
else
dH, dV = dV, dH
end
-- se lavorazione da sotto e lunga, va divisa in due metà
local bDouble = ( vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200))
-- 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
sName = EgtGetName( nMchFId)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso del lato faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHeadDir, 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)
if vtN:getZ() < - 0.5 and ( nStep % 2) == 0 then
nStep = nStep + 1
end
dStep = dVcalc / nStep + 0.1
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)
-- attacchi e uscite
if vtN:getZ() > -0.5 then
EgtSetMachiningParam( MCH_MP.LITANG, 0)
EgtSetMachiningParam( MCH_MP.LIPERP, dFacElev + BD.CUT_SIC)
else
EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + BD.CUT_SIC)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR)
EgtSetMachiningParam( MCH_MP.LOTANG, 0)
EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev + BD.COLL_SIC)
if bDouble then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, - dH / 2)
end
end
-- tipo passate multiple
local nStepType = EgtIf( ( Proc.HeadDir and vtN:getY() < -0.5) or ( not Proc.HeadDir and vtN:getY() > 0.5), MCH_MILL_ST.ONEWAY, MCH_MILL_ST.ZIGZAG)
EgtSetMachiningParam( MCH_MP.STEPTYPE, nStepType)
-- imposto posizione braccio porta testa
local nSCC = EgtIf( ( vtN:getY() > 0.5 or ( bHeadDir and vtN:getZ() > 0.5 ) or ( not bHeadDir and vtN:getZ() < -0.5)), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- se divisa in due metà
if bDouble then
local nMchFNId = EgtCopyMachining( sName .. '_2', sName)
if not nMchFNId then
local sErr = 'Error copying machining ' .. sName
EgtOutLog( sErr)
return false, sErr
end
-- inverto direzione e lato di lavoro e direzione ausiliaria
local bInvert = EgtGetMachiningParam( MCH_MP.INVERT)
EgtSetMachiningParam( MCH_MP.INVERT, not bInvert)
local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE)
EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT))
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( nSCC == MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFNId, false)
return false, sErr
end
end
return true, ''
end
local function AreFacesOrthogonal( nSurfId, nFacInd, nFacInd2, dCosSideAng)
-- recupero il numero di facce
if not dCosSideAng then
dCosSideAng = -0.09
end
-- recupero le normali delle facce
local vtN = EgtSurfTmFacetNormVersor( nSurfId, nFacInd, GDB_ID.ROOT)
local vtN2 = EgtSurfTmFacetNormVersor( nSurfId, nFacInd2, GDB_ID.ROOT)
-- ne determino eventuale sottosquadra ( dal valore passato o - 5deg) e ortogonalità
local dOrtho = 0 -- orthogonal
local dResV = vtN * vtN2
if dResV < dCosSideAng - GEO.EPS_SMALL then
dOrtho = -1 -- undercut
end
if abs( dResV) > 2 * GEO.EPS_SMALL then
dOrtho = 1 -- overcut
end
return dOrtho
end
---------------------------------------------------------------------
local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmHead, b3Raw, nChamfer)
local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId)
-- entrambe le facce non devono essere orientate verso il basso
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
-- se orientata verso il basso, verifico l'alternativa
if vtN:getZ() < BD.NZ_MINA and vtN2:getZ() < BD.NZ_MINA then
local sErr = 'Error : special LapJoint from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd2, GDB_ID.ROOT)
-- eventuali tagli preliminari
do
local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer)
if not bOk then return false, sErr end
end
-- Recupero la lavorazione di fresa
local sMilling = ML.FindMilling( 'LongSmallCut')
if not sMilling then
local sErr = 'Error : LongSmallCut not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- Recupero la lavorazione di svuotatura
local sMchFind = 'Pocket'
-- se forzato uso truciolatore
if Q_USE_ROUGH_TOOL == 1 then
sMchFind = 'OpenPocket'
end
local dDiam = min( dH, dV)
local dDiam2 = min( dH2, dV2)
local dCollSic = 2 * BD.COLL_SIC
local dCollSic2 = 2 * BD.COLL_SIC
if abs( vtN:getX()) > 0.7 or abs( vtN:getY()) > 0.7 or abs( vtN:getZ()) > 0.7 then dCollSic = 0 end
if abs( vtN2:getX()) > 0.7 or abs( vtN2:getY()) > 0.7 or abs( vtN2:getZ()) > 0.7 then dCollSic2 = 0 end
local sPocketing
-- <LB> controllo se le facce sono ortogonali o meno
local dOrtho = AreFacesOrthogonal(Proc.Id, nFacInd, nFacInd2)
local nPockFace
--if bUseNewMethod == false then
if (dOrtho == 0) then -- ortogonali
sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2)
nPockFace = nFacInd2
elseif (dOrtho > 0) then -- overcut (angolo aperto)
-- <LB> prendo prima la faccia 1
sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic)
nPockFace = nFacInd
else
local sErr = 'Error : special LapJoint with undercut face is not managed'
EgtOutLog( sErr)
return false, sErr
end
-- se non trova una svuotatura adatta provo ad assegnarla all'altra faccia
if not sPocketing then
--if bUseNewMethod == false then
if (dOrtho == 0) then
-- <LB> se ortogonali, 'swappa' le 2 facce
dDiam, dDiam2 = dDiam2, dDiam
dCollSic, dCollSic2 = dCollSic2, dCollSic
nFacInd, nFacInd2 = nFacInd2, nFacInd
dH, dH2 = dH2, dH
dV, dV2 = dV2, dV
dFacElev, dFacElev2 = dFacElev2, dFacElev
rfFac, rfFac2 = rfFac2, rfFac
vtN, vtN2 = vtN2, vtN
end
nPockFace = nFacInd2
sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2)
if not sPocketing then
local sErr = 'Error : '..sMchFind..' not found in library'
EgtOutLog( sErr)
return false, sErr
end
end
EgtOutLog( '*** nFacInd=' .. tostring(nFacInd))
EgtOutLog( '*** nFacInd2=' .. tostring(nFacInd2))
EgtOutLog( '*** Pocketing Face=' .. tostring(nPockFace))
-- provo con contornatura
local dDiamTool = 20
if bIsL then
local bOk, sWarn
bOk, sWarn, dDiamTool = MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, dCollSic, true, sMilling, nFacInd2, dFacElev2)
if not bOk then return bOk, sWarn end
else
local sErr = 'Error : Impossible mill special LapJoint'
EgtOutLog( sErr)
return false, sErr
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
-- <LB>
sName = sName .. '_F' .. tostring(nPockFace)
-- <LB>
local nMchFId = EgtAddMachining( sName, sPocketing)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
EgtOutLog( sErr)
return false, sErr
end
EgtOutLog( '*** -----------------------------------------------------------------')
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nPockFace}})
-- 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
-- imposto elevazione
local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev2, 1) .. ';'
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 abilitato dal parametro Q inserisco foro sullo spigolo
if Q_BORE_ON_CORNER == 1 then
local bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool, true)
if not bOk then return false, sWarn end
-- altrimenti se abilitato dal parametro Q inserisco percorso di pulitura
elseif Q_BORE_ON_CORNER == 2 then
local bOk, sWarn = MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool)
if not bOk then return false, sWarn end
end
return true, ''
end
---------------------------------------------------------------------
local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill)
local sWarn
@@ -4514,225 +4813,47 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
if bMakeBySideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then
-- se smusso non è esclusivo
if nChamfer < 2 then
if Proc.Fct > 1 then
-- recupero la larghezza della faccia perpendicolarmente alle altre 2
local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT)
local vtX = vtN2 ^ vtN
local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2)
local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef)
if b3Ref then
dV = b3Ref:getDimY()
dH = b3Ref:getDimX()
end
else
dH, dV = dV, dH
end
-- se lavorazione da sotto e lunga, va divisa in due metà
local bDouble = ( vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200))
-- 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
sName = EgtGetName( nMchFId)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso del lato faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHeadDir, 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)
if vtN:getZ() < - 0.5 and ( nStep % 2) == 0 then
nStep = nStep + 1
end
dStep = dVcalc / nStep + 0.1
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)
-- attacchi e uscite
if vtN:getZ() > -0.5 then
EgtSetMachiningParam( MCH_MP.LITANG, 0)
EgtSetMachiningParam( MCH_MP.LIPERP, dFacElev + BD.CUT_SIC)
else
EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + BD.CUT_SIC)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR)
EgtSetMachiningParam( MCH_MP.LOTANG, 0)
EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev + BD.COLL_SIC)
if bDouble then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, - dH / 2)
end
end
-- tipo passate multiple
local nStepType = EgtIf( ( Proc.HeadDir and vtN:getY() < -0.5) or ( not Proc.HeadDir and vtN:getY() > 0.5), MCH_MILL_ST.ONEWAY, MCH_MILL_ST.ZIGZAG)
EgtSetMachiningParam( MCH_MP.STEPTYPE, nStepType)
-- imposto posizione braccio porta testa
local nSCC = EgtIf( ( vtN:getY() > 0.5 or ( bHeadDir and vtN:getZ() > 0.5 ) or ( not bHeadDir and vtN:getZ() < -0.5)), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- se divisa in due metà
if bDouble then
local nMchFNId = EgtCopyMachining( sName .. '_2', sName)
if not nMchFNId then
local sErr = 'Error copying machining ' .. sName
EgtOutLog( sErr)
return false, sErr
end
-- inverto direzione e lato di lavoro e direzione ausiliaria
local bInvert = EgtGetMachiningParam( MCH_MP.INVERT)
EgtSetMachiningParam( MCH_MP.INVERT, not bInvert)
local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE)
EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT))
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( nSCC == MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFNId, false)
return false, sErr
end
end
local bOk, sErr = MakeBySideMill()
return bOk, sErr
end
-- altrimenti lavoro con svuotatura
else
local bSpecial3faces = false
local bUseNewMethod = false
EgtOutLog( '*** -----------------------------------------------------------------')
EgtOutLog( '*** new method=' .. EgtIf( bUseNewMethod, 'YES', 'NO'))
-- verifico se lavorando la faccia principale rimane esclusa molta sezione trasversale complessiva della feature (da box)
local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
local bBoxF = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfFac)
-- <LB> if dH * dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then
if dH * dV < 0.99 * ( bBoxF:getDimX() * bBoxF:getDimY()) then
bSpecial3faces = true
if bUseNewMethod == false then
if dH * dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then
bSpecial3faces = true
end
else
-- <LB> diminuisco la differenza per cui considero la lavorazione come "speciale" per lavorare anche con angoli prossimi all'ortogonalità
if dH * dV < 0.97 * ( bBoxF:getDimX() * bBoxF:getDimY()) then
bSpecial3faces = true
end
end
EgtOutLog( '*** bSpecial3faces=' .. EgtIf( bSpecial3faces, 'YES', 'NO'))
-- se riconosciuta gestione 3 facce
-- e limitata per ora alla feature 20
if bSpecial3faces and Proc.Prc == 20 and nFacInd2 then
--- <LB> ---
--ShowFacesNumber( Proc.Id)
-- se smusso non è esclusivo
if nChamfer < 2 then
-- entrambe le facce non devono essere orientate verso il basso
local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
-- se orientata verso il basso, verifico l'alternativa
if vtN:getZ() < BD.NZ_MINA and vtN2:getZ() < BD.NZ_MINA then
local sErr = 'Error : special LapJoint from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd2, GDB_ID.ROOT)
-- eventuali tagli preliminari
do
local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer)
if not bOk then return false, sErr end
end
-- Recupero la lavorazione di fresa
local sMilling = ML.FindMilling( 'LongSmallCut')
if not sMilling then
local sErr = 'Error : LongSmallCut not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- Recupero la lavorazione di svuotatura
local sMchFind = 'Pocket'
-- se forzato uso truciolatore
if Q_USE_ROUGH_TOOL == 1 then
sMchFind = 'OpenPocket'
end
local dDiam = min( dH, dV)
local dDiam2 = min( dH2, dV2)
local dCollSic = 2 * BD.COLL_SIC
local dCollSic2 = 2 * BD.COLL_SIC
if abs( vtN:getX()) > 0.7 or abs( vtN:getY()) > 0.7 or abs( vtN:getZ()) > 0.7 then dCollSic = 0 end
if abs( vtN2:getX()) > 0.7 or abs( vtN2:getY()) > 0.7 or abs( vtN2:getZ()) > 0.7 then dCollSic2 = 0 end
-- <LB> local sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2)
local sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic)
local nPockFace = nFacInd -- <LB>
-- se non trova una svuotatura adatta provo ad assegnarla all'altra faccia
if not sPocketing then
-- <LB> dDiam, dDiam2 = dDiam2, dDiam
-- <LB> dCollSic, dCollSic2 = dCollSic2, dCollSic
-- <LB> nFacInd, nFacInd2 = nFacInd2, nFacInd
-- <LB> dH, dH2 = dH2, dH
-- <LB> dV, dV2 = dV2, dV
-- <LB> dFacElev, dFacElev2 = dFacElev2, dFacElev
-- <LB> rfFac, rfFac2 = rfFac2, rfFac
-- <LB> vtN, vtN2 = vtN2, vtN
-- <LB> sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2)
sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2)
nPockFace = nFacInd2 -- <LB>
if not sPocketing then
local sErr = 'Error : '..sMchFind..' not found in library'
EgtOutLog( sErr)
return false, sErr
end
end
-- provo con contornatura
local dDiamTool = 20
if bIsL then
local bOk, sErr
bOk, sWarn, dDiamTool = MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, dCollSic, true, sMilling, nFacInd2, dFacElev2)
if not bOk then return bOk, sWarn end
else
local sErr = 'Error : Impossible mill special LapJoint'
EgtOutLog( sErr)
return false, sErr
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
-- <LB> EgtSetMachiningGeometry( {{ Proc.Id, nFacInd2}})
EgtSetMachiningGeometry( {{ Proc.Id, nPockFace}})
-- 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
-- imposto elevazione
local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev2, 1) .. ';'
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 abilitato dal parametro Q inserisco foro sullo spigolo
if Q_BORE_ON_CORNER == 1 then
local bOk
bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool, true)
if not bOk then return false, sWarn end
-- altrimenti se abilitato dal parametro Q inserisco percorso di pulitura
elseif Q_BORE_ON_CORNER == 2 then
local bOk
bOk, sWarn = MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool)
if not bOk then return false, sWarn end
end
end
local bOk, sErr = MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmHead, b3Raw, nChamfer)
return bOk, sErr
end
-- altrimenti lavorazione di svuotatura o contornatura
else
local bUseOtherFace
@@ -5101,7 +5222,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
bTryWithBlades = false
sWarn = sErr
-- se ho antischeggia con fresa le inserisco
-- if nChamfer < 2 and nQAntisplintResult == 2 and ( bIsU or bIsL) then
-- if nChamfer < 2 and nQAntisplintResult == 2 and ( bIsU or bIsL) then
if nChamfer < 2 and nQAntisplintResult == 2 then
local bOk, sWarn2 = ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw,
nFacInd, nAddGrpId, bMillDown, dDiamTool, bDoubleSide,
@@ -5299,7 +5420,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
return true, sWarn, bPrevBhSideMill
end
---------------------------------------------------------------------
local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- recupero gruppo per geometria addizionale
+1 -1
View File
@@ -8,7 +8,7 @@
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( true)
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Travi
local sBaseDir = EgtGetSourceDir()