- aggiunta funzione DoPocket()
This commit is contained in:
+86
-155
@@ -3445,16 +3445,65 @@ local function GetUShapeWidth( Proc, nFacInd)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster, bMillDown)
|
||||
local function DoPocket( sName, sPocketing, sMchFind, vtN, nPathInt, nFaceIdx, dMachDepth, sNotes, bInvert)
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
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, nFaceIdx}})
|
||||
if bInvert then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
end
|
||||
-- imposto posizione braccio porta testa
|
||||
local nSCC = MCH_SCC.NONE
|
||||
if not BD.C_SIMM then
|
||||
if AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
elseif abs( vtN:getX()) < 0.1 then
|
||||
nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
elseif vtN:getY() < GEO.EPS_SMALL then
|
||||
nSCC = EgtIf( bInvert, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
nSCC = EgtIf( bInvert, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- se tasca aperta, imposto opportuno attacco
|
||||
if sMchFind == 'OpenPocket' or sMchFind == 'OpenPocket_H2' then
|
||||
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
|
||||
end
|
||||
-- inverto il percorso di lavorazione per lavorare sinistro
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- imposto affondamento
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMachDepth)
|
||||
-- imposto usernotes
|
||||
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
|
||||
|
||||
return true, '', nMchFId
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeByPockets( Proc, bIs3Faces, bOrthoFacesMaster, bMillDown)
|
||||
local nFirstMachId
|
||||
local bOrthoFaces
|
||||
local sWarn
|
||||
local sMchFind = 'Pocket'
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt
|
||||
local bBadMach = false
|
||||
if sMchFindMaster and #sMchFindMaster > 0 then
|
||||
sMchFind = sMchFindMaster
|
||||
end
|
||||
if bIs3Faces then
|
||||
-- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa
|
||||
local nFacInd, _, nFacInd2, _ = BL.GetFaceWithMostAdj( Proc.Id, _nPartId, bIs3Faces)
|
||||
@@ -3559,64 +3608,25 @@ local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster
|
||||
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)
|
||||
-- imposto elevazione e dichiaro non si generano sfridi per VMill
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';VMRS=0;'
|
||||
local bInvert = false
|
||||
-- verifico se devo invertire direzione utensile (in caso di direzione verso la verticale)
|
||||
if vtOrtho:getZ() < BD.NZ_MINA and abs(vtOrtho:getZ()) >= 0.707 and not BD.DOWN_HEAD then
|
||||
bInvert = 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 and not ( -(vtOrtho:getZ()) < BD.NZ_MINA) then
|
||||
bInvert = true
|
||||
end
|
||||
-- eseguo svuotatura
|
||||
local bOk, sErr, nMchFId = DoPocket( sName, sPocketing, sMchFind, vtOrtho, nPathInt, -1, dMachDepth, sNotes, bInvert)
|
||||
if not bOk then
|
||||
return -1, sErr
|
||||
end
|
||||
-- prendo l'id della prima lavorazione inserita
|
||||
if not nFirstMachId then
|
||||
nFirstMachId = nMchFId
|
||||
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 and not BD.DOWN_HEAD 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 and not ( -(vtOrtho:getZ()) < BD.NZ_MINA) then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
bInvertMach = true
|
||||
end
|
||||
-- imposto posizione braccio porta testa
|
||||
local nSCC = MCH_SCC.NONE
|
||||
if not BD.C_SIMM then
|
||||
if AreSameOrOppositeVectorApprox( vtOrtho, Z_AX()) then
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
elseif abs( vtOrtho:getX()) < 0.1 then
|
||||
nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
elseif vtOrtho:getY() < GEO.EPS_SMALL then
|
||||
nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- se tasca aperta, imposto opportuno attacco
|
||||
if sMchFind == 'OpenPocket' or sMchFind == 'OpenPocket_H2' then
|
||||
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
|
||||
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 -1, sErr
|
||||
end
|
||||
end
|
||||
-- se posso applicare la svuotatura sul lato opposto
|
||||
if bDoubleSide then
|
||||
-- se ho la lavorazione da sotto ricalcolo in base a questa lavorazione
|
||||
@@ -3649,56 +3659,17 @@ local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = 'PockOppo_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchFId = EgtAddMachining( sName, EgtIf( bMakePocketDn, sPocketingDn, sPocketing))
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. EgtIf( bMakePocketDn, sPocketingDn, sPocketing)
|
||||
EgtOutLog( sErr)
|
||||
-- imposto elevazione e dichiaro non si generano sfridi per VMill
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';VMRS=0;'
|
||||
-- eseguo svuotatura in direzione invertita
|
||||
local bOk, sErr, nMchFId = DoPocket( sName, sPocketing, sMchFind, vtOrtho, nPathInt, -1, dMachDepth, sNotes, true)
|
||||
if not bOk then
|
||||
return -1, sErr
|
||||
end
|
||||
-- prendo l'id della prima lavorazione inserita
|
||||
if not nFirstMachId then
|
||||
nFirstMachId = nMchFId
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ nPathInt, -1}})
|
||||
-- imposto direzione utensile opposta
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
-- imposto posizione braccio porta testa
|
||||
local nSCC = MCH_SCC.NONE
|
||||
if not BD.C_SIMM then
|
||||
if AreSameVectorApprox( vtOrtho, Z_AX()) then
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
elseif abs( vtOrtho:getX()) < 0.1 then
|
||||
nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
elseif vtOrtho:getY() < GEO.EPS_SMALL then
|
||||
nSCC = MCH_SCC.ADIR_YP
|
||||
else
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
end
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- se tasca aperta, imposto opportuno attacco
|
||||
if sMchFind == 'OpenPocket' or sMchFind == 'OpenPocket_H2' then
|
||||
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
|
||||
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 -1, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se non completo e U, cerco di lavorare anche la faccia di fondo (con il massimo affondamento possibile)
|
||||
if not bComplete and bIs3Faces then
|
||||
@@ -3715,60 +3686,23 @@ local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster
|
||||
local dFacCollSic = CalcCollisionSafety( vtN)
|
||||
-- scelgo se lavorare da sotto
|
||||
local bFacPocketDn = ( bMakePocketDn and vtN:getZ() < -0.174)
|
||||
-- calcolo affondamento
|
||||
local dDepth = 0
|
||||
local dActMaxDepth = EgtIf( bFacPocketDn, dMaxDepthDn, dMaxDepth)
|
||||
if dActMaxDepth < dFacElev + dFacCollSic then
|
||||
dDepth = dActMaxDepth - dFacElev + dFacCollSic
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = EgtIf( bDoubleSide, 'Pock3rd_', 'Pock2nd_') .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchFId = EgtAddMachining( sName, EgtIf( bFacPocketDn, sPocketingDn, sPocketing))
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
|
||||
EgtOutLog( sErr)
|
||||
-- eseguo svuotatura
|
||||
local bOk, sErr, nMchFId = DoPocket( sName, sPocketing, sMchFind, vtN, Proc.Id, nFacInd, dDepth, 'VMRS=0;', false)
|
||||
if not bOk then
|
||||
return -1, sErr
|
||||
end
|
||||
-- prendo l'id della prima lavorazione inserita
|
||||
if not nFirstMachId then
|
||||
nFirstMachId = nMchFId
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
|
||||
-- imposto posizione braccio porta testa
|
||||
local nSCC = MCH_SCC.NONE
|
||||
if not BD.C_SIMM then
|
||||
if AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
elseif abs( vtN:getX()) < 0.1 then
|
||||
nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
elseif vtN:getY() < GEO.EPS_SMALL then
|
||||
nSCC = MCH_SCC.ADIR_YM
|
||||
else
|
||||
nSCC = MCH_SCC.ADIR_YP
|
||||
end
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- se tasca aperta, imposto opportuno attacco
|
||||
if sMchFind == 'OpenPocket' or sMchFind == 'OpenPocket_H2' then
|
||||
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
|
||||
end
|
||||
-- inverto il percorso di lavorazione per lavorare sinistro
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- imposto affondamento
|
||||
local dDepth = 0
|
||||
local dActMaxDepth = EgtIf( bFacPocketDn, dMaxDepthDn, dMaxDepth)
|
||||
if dActMaxDepth < dFacElev + dFacCollSic then
|
||||
dDepth = dActMaxDepth - dFacElev + dFacCollSic
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- dichiaro non si generano sfridi per VMill
|
||||
local 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 -1, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return 1, sWarn, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId
|
||||
@@ -4010,7 +3944,7 @@ local function MakeAntiSplintByMill( Proc, pPaths, nPathInt, vtN1,
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMachDepth)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, bInvert)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, (dMachDepth+dExtraDepth))
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, (dMachDepth + dExtraDepth))
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bInvertMach, not bInvert, bInvert))
|
||||
end
|
||||
-- Note utente con dichiarazione nessuna generazione sfridi per Vmill
|
||||
@@ -4539,9 +4473,8 @@ local function MakeSidePocketings( Proc, FData, dCollSic, bSpecialMillOnSide,
|
||||
-- o passare subito dalla lavorazione con lama/sega catena
|
||||
if Proc.Fct == 3 and bIsU then
|
||||
-- lavoro con svuotature (singola o doppia contrapposta)
|
||||
local sMyMchFind = 'Pocket'
|
||||
nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, _, _, _, _, _, _, _,
|
||||
bOrthoFaces = MakeByPockets( Proc, sMyMchFind, true, nil, bMillDown)
|
||||
bOrthoFaces = MakeByPockets( Proc, true, nil, bMillDown)
|
||||
-- se lavorazione non idonee (asse della feature troppo inclinato e impossibile lavorare completamente da due parti)
|
||||
if nOk == -2 then
|
||||
if not sMchFind then
|
||||
@@ -4612,11 +4545,10 @@ local function MakeSidePocketings( Proc, FData, dCollSic, bSpecialMillOnSide,
|
||||
-- o passare subito dalla lavorazione con lama/sega catena
|
||||
if _bTrySidePocketAtFirst and Proc.Fct == 3 and bIsU then
|
||||
-- lavoro con svuotature (singola o doppia contrapposta)
|
||||
local sMyMchFind = 'Pocket'
|
||||
local dDiamTool = 100
|
||||
local nPathInt, nSurfInt, bOneShot, nFirstMachId, bDoubleSide
|
||||
nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool,
|
||||
bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, bOrthoFaces = MakeByPockets( Proc, sMyMchFind, true, nil, bMillDown)
|
||||
bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, bOrthoFaces = MakeByPockets( Proc, true, nil, bMillDown)
|
||||
if nOk == -2 then
|
||||
if not sMchFind then
|
||||
sMchFind = sMchFindBackUp
|
||||
@@ -5166,8 +5098,7 @@ local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill)
|
||||
if bClosedOrthoFaces then
|
||||
local bTryWithBlades = true
|
||||
-- lavoro fessura con svuotature (singola o doppia contrapposta)
|
||||
local sMyMchFind = 'Pocket'
|
||||
local nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace = MakeByPockets( Proc, sMyMchFind, false, bClosedOrthoFaces)
|
||||
local nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace = MakeByPockets( Proc, false, bClosedOrthoFaces)
|
||||
if nOk < 0 then
|
||||
return false, sErr
|
||||
elseif nOk > 0 then
|
||||
|
||||
Reference in New Issue
Block a user