DataBeam :

- gestione completa Fessure Passanti
- completata gestione Profili.
This commit is contained in:
Dario Sassi
2020-02-28 19:23:51 +00:00
parent 8441f3ca61
commit e6630ca547
4 changed files with 1075 additions and 284 deletions
+13 -3
View File
@@ -331,6 +331,7 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId)
-- adiacenze e sottosquadra delle facce
local vAdj = {}
local vUcut = {}
local vOrtho = {}
for i = 1, nFacCnt do
-- recupero le adiacenze del loop esterno
local vFacAdj = EgtSurfTmFacetAdjacencies( nSurfId, i - 1)[1]
@@ -342,23 +343,32 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId)
end
end
vAdj[i] = nCount
-- ne determino eventuale sottosquadra (- 3deg)
-- ne determino eventuale sottosquadra (- 3deg) e ortogonalità
local bUcut = false
local bOrto = false
for j = 1, #vFacAdj do
if vFacAdj[j] >= 0 then
local vtN = vvtN[i]
local vtN2 = vvtN[vFacAdj[j]+1]
if vtN * vtN2 < -0.05 then
local dResV = vtN * vtN2
if dResV < -0.05 then
bUcut = true
elseif abs(dResV) < GEO.EPS_SMALL then
bOrtho = true
end
end
end
vUcut[i] = bUcut
vOrtho[i] = bOrtho
end
-- se 4 facce tutte con adiacenza 2, allora è un tunnel
if nFacCnt == 4 then
if vAdj[1] == 2 and vAdj[2] == 2 and vAdj[3] == 2 and vAdj[4] == 2 then
return -1, GEO.INFINITO
if vOrtho[1] == true and vOrtho[2] == true and vOrtho[3] == true and vOrtho[4] == true then
return -1, GEO.INFINITO, true
else
return -1, GEO.INFINITO
end
end
end
-- recupero le facce non in sottosquadra e con il maggior numero di adiacenze
+618 -163
View File
@@ -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
+2 -1
View File
@@ -527,7 +527,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nLastFacet}})
-- aggiusto i parametri
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, false)
EgtSetMachiningParam( MCH_MP.WORKSIDE, 1)
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
EgtSetMachiningParam( MCH_MP.STEP, 0)
EgtSetMachiningParam( MCH_MP.OFFSR, -0.5)
+442 -117
View File
@@ -15,6 +15,14 @@ EgtOutLog( ' ProcessProfFront started', 1)
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
-- variabili assegnazione parametri Q
local sEnableExtraMillUpperFace = '' -- i
local sEnableExtraBladeUpperFace = '' -- i
local sDepthChamferMill = 'Q01' -- d
local sOverMaterialForFinish = 'Q02' -- d
local sPreemptiveChamfer = 'Q03' -- i
local sMachFacesUnderneath = 'Q99' -- i
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessProfFront.Identify( Proc)
@@ -33,6 +41,112 @@ local function GetSawCutData( AuxId, vtN)
return ptStart, vtNP
end
---------------------------------------------------------------------
local function ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, bNotModifLeadPar)
-- confronto il punto iniziale e finale della lavorazione con il box della feature
-- e se è vicino alla parte esterna della trave inverto la lavorazione
ptSP = EgtGetMachiningStartPoint()
ptEp = EgtGetMachiningEndPoint()
local nMachMode = EgtGetMachiningParam( MCH_MP.STEPTYPE)
if nMachMode == 1 and ptSP and ptEp then
if abs( EgtIf( bHead, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) - ptSP:getX()) <
abs( EgtIf( bHead, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) - ptEp:getX()) then
-- ottengo il lato lavoro e lo inverto
local nSideWork = EgtGetMachiningParam( MCH_MP.WORKSIDE)
if nSideWork > 0 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nSideWork == MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT))
end
-- ottengo l'inversione e setto il contrario
local bInvertMode = EgtGetMachiningParam( MCH_MP.INVERT)
EgtSetMachiningParam( MCH_MP.INVERT, not bInvertMode)
-- modifico attacco e uscita
if not bNotModifLeadPar then
EgtSetMachiningParam( MCH_MP.LIPERP, -(dToolDiam/2))
EgtSetMachiningParam( MCH_MP.LITANG, (dToolDiam/2)+0.5)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, 0)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, (dToolDiam/3*2))
end
-- riapplico la lavorazione
EgtApplyMachining()
else
-- modifico attacco e uscita
if not bNotModifLeadPar then
EgtSetMachiningParam( MCH_MP.LIPERP, -(dToolDiam/2))
EgtSetMachiningParam( MCH_MP.LITANG, (dToolDiam/2)+0.5)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, 0)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, (dToolDiam/3*2))
-- riapplico la lavorazione
EgtApplyMachining()
end
end
end
end
---------------------------------------------------------------------
local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnlyCham)
local nChamfer = 0
-- ingombro del grezzo
local b3Raw = EgtGetRawPartBBox( nRawId)
-- 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
-- recupero i dati della curva e del profilo
local dWidth = abs( EgtCurveThickness( AuxId))
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
local nCanVert = 0
-- eseguo lo smusso solo se direzione orizzontale e il flag di lavorazione verticale è disabilitato
if abs( vtExtr:getZ()) > 0.1 then
if not bMakeVertCham then
if nChamfer == 2 then -- se devo fare solo smusso, genero errore
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' not horizontale chamfer'
EgtOutLog( sErr)
return -1, dDepth, sErr
else
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped not horizontale chamfer'
EgtOutLog( sWarn)
return 0, dDepth
end
else
nCanVert = 1
end
end
-- eseguo lo smusso solo se feature larga come la trave
if dWidth < EgtIf( nCanVert == 1, b3Raw:getDimZ(), b3Raw:getDimY()) - 1 then
if nChamfer == 2 then -- se devo fare solo smusso, genero errore
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' feature smaller than beam'
EgtOutLog( sErr)
return -1, dDepth, sErr
else
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped chamfer (feature smaller than beam)'
EgtOutLog( sWarn)
return 0, dDepth
end
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
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
@@ -57,6 +171,7 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
-- recupero i dati della curva e del profilo
local dProfDepth = abs( EgtCurveThickness( AuxId))
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
local nFirstFacet = 0 -- faccia iniziale
local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- ultima faccia
local nRefFacet = nLastFacet - 1 -- penultima faccia
-- determino la normale media
@@ -73,6 +188,12 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
elseif vtN:getZ() < -0.1 then
nSide = -1
end
-- verifico se necessari ripassi agli estremi negli angoli
local _, _, _, dFirstAng = EgtSurfTmFacetsContact( Proc.Id, nFirstFacet, nFirstFacet + 1, GDB_ID.ROOT)
local bFirstTrim = ( dFirstAng and dFirstAng < -30)
-- verifico se necessari ripassi agli estremi negli angoli
local _, _, _, dLastAng = EgtSurfTmFacetsContact( Proc.Id, nLastFacet, nLastFacet - 1, GDB_ID.ROOT)
local bLastTrim = ( dLastAng and dLastAng < -30)
-- recupero gruppo per geometria addizionale
local nAddGrpId = BL.GetAddGroup( nPartId)
if not nAddGrpId then
@@ -80,83 +201,146 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo taglio di lama di sgrossatura e lo lavoro
local ptStart, vtNP = GetSawCutData( AuxId, vtN)
local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB)
if AddId then
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
EgtSetInfo( AddId, 'TASKID', Proc.TaskId)
-- applico la lavorazione
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
if not bOk then return bOk, sErr end
-- verifico se sono presenti i parametri Q per la profondità smusso e
-- per eseguire in esclusiva solo lo smusso
local nChamfer, dDepthCham, sChamfer = VerifyCham( Proc, AuxId, nRawId, false, sDepthChamferMill, sPreemptiveChamfer)
-- 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
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'Prof')
if not sMilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- Recupero i dati dell'utensile
local dToolMaxDepth = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolMaxDepth = EgtTdbGetCurrToolMaxDepth()
-- se smusso non è esclusivo
if nChamfer < 2 then
-- aggiungo taglio di lama di sgrossatura e lo lavoro
local ptStart, vtNP = GetSawCutData( AuxId, vtN)
local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB)
if AddId then
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
EgtSetInfo( AddId, 'TASKID', Proc.TaskId)
-- applico la lavorazione
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
if not bOk then return bOk, sErr end
end
end
-- verifico se necessario lavorare in doppio
local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth)
local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP)
-- inserisco la lavorazione
local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- se lavorazione da sopra o da sotto
if nSide ~= 0 then
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() < -0.1) or
( not bHead and vtExtr:getY() > 0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- altrimenti lavorazione dal davanti o dal dietro
else
-- se fresa verso il basso, la porto verso l'alto
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- se lavorazione a destra da dietro o sinistra di fronte, inverto
if ( bHead and vtN:getY() > 0.1) or
( not bHead and vtN:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
end
-- se in doppio, imposto l'affondamento
if bDouble then
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
end
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
-- se lavorazione da due parti, aggiungo la seconda
if bDouble then
-- se devo inserire il chamfer
if nChamfer > 0 then
local bDoubleCham = false
local dExtra = 2
-- inserisco la lavorazione
local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sNameCh, sChamfer)
if not nMchId then
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- se lavorazione da sopra o da sotto
if nSide ~= 0 then
bDoubleCham = true
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() < -0.1) or
( not bHead and vtExtr:getY() > 0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- altrimenti lavorazione dal davanti o dal dietro
else
-- se fresa verso il basso, la porto verso l'alto
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- se lavorazione a destra da dietro o sinistra di fronte, inverto
if ( bHead and vtNF:getY() > 0.1) or
( not bHead and vtNF:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
end
-- assegno affondamento e offset radiale
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
-- allungo inizio e fine attacco
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 10)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 10)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
else
-- applico controllo del punto entrata lavorazione e se non è distante dall'esterno
-- della feature inverto il punto di inizio della lavorazione
ModifySideAndInvertAndLead( Proc, bHead, dMillDiam, true)
end
-- se lavorazione da due parti, aggiungo la seconda
if bDoubleCham then
-- inserisco la lavorazione
local sName = 'ChamB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sChamfer)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sChamfer
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- sempre lavorazione da sopra o da sotto
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() > 0.1) or
( not bHead and vtExtr:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- assegno affondamento e offset radiale
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
-- allungo inizio e fine attacco
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 10)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 10)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
else
-- applico controllo del punto entrata lavorazione e se non è distante dall'esterno
-- della feature inverto il punto di inizio della lavorazione
ModifySideAndInvertAndLead( Proc, bHead, dMillDiam, true)
end
end
end
-- se il chamfer non è esclusivo continuo con le altre lavorazioni
if nChamfer < 2 then
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'Prof')
if not sMilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- Recupero i dati dell'utensile
local dToolMaxDepth = 0
local dToolDiam = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolMaxDepth = EgtTdbGetCurrToolMaxDepth()
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
end
end
-- verifico se necessario lavorare in doppio
local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth)
local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP)
-- inserisco la lavorazione
local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
@@ -165,70 +349,211 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- sempre lavorazione da sopra o da sotto
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() > 0.1) or
( not bHead and vtExtr:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
-- se lavorazione da sopra o da sotto
if nSide ~= 0 then
if not bDouble and nSide == -1 then
-- se lavorazione a sinistra di fronte o destra da dietro, inverto
if ( bHead and vtExtr:getY() > 0.1) or
( not bHead and vtExtr:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
else
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() < -0.1) or
( not bHead and vtExtr:getY() > 0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
end
-- altrimenti lavorazione dal davanti o dal dietro
else
-- se fresa verso il basso, la porto verso l'alto
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- se lavorazione a destra da dietro o sinistra di fronte, inverto
if ( bHead and vtN:getY() > 0.1) or
( not bHead and vtN:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
end
-- se in doppio, imposto l'affondamento
if bDouble then
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
end
-- imposto l'affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
-- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale
local ptSP, ptEp
local bFinish
local dOriOffset = 0
local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0
-- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale
if dOffsetPar > 0 then
EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar))
bFinish = true
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
else
-- applico controllo del punto entrata lavorazione e se non è distante dall'esterno
-- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco
-- e uscita
ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true)
end
end
-- se non da sotto, inserisco lavorazione finitura angolo
if nSide ~= -1 then
sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchVId = EgtAddMachining( sName, sMilling)
if not nMchVId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
-- se abilitata, aggiungo lavorazione di finitura
if bFinish then
-- inserisco la lavorazione
local sNewName = 'Prof_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtCopyMachining( sNewName, sName)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
else
-- riporto il sovramateriale originale e tolgo i passi
EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset)
EgtSetMachiningParam( MCH_MP.STEP, 0)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
end
-- calcolo massima elevazione
local _, _, _, _, _, _, dWidth = EgtSurfTmFacetOppositeSide( Proc.Id, 0, EgtIf( bHead, X_AX(), - X_AX()), GDB_ID.ROOT)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, 0}})
-- aggiusto i parametri
EgtSetMachiningParam( MCH_MP.INVERT, false)
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
EgtSetMachiningParam( MCH_MP.STEP, 0)
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1))
-- imposto tipo uso faccia
local nFaceUse = MCH_MILL_FU.PARAL_DOWN
if nSide ~= 1 then
nFaceUse = EgtIf( vtN:getY() > 0.1, MCH_MILL_FU.PARAL_FRONT, MCH_MILL_FU.PARAL_BACK)
-- se lavorazione da due parti, aggiungo la seconda
if bDouble then
-- inserisco la lavorazione
local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- sempre lavorazione da sopra o da sotto
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
if ( bHead and vtExtr:getY() > 0.1) or
( not bHead and vtExtr:getY() < -0.1) then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- imposto l'affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
-- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente
if dOffsetPar > 0 then
EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar))
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
else
-- applico controllo del punto entrata lavorazione e se non è distante dall'esterno
-- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco
-- e uscita
ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true)
end
-- se abilitata, aggiungo lavorazione di finitura
if bFinish then
-- inserisco la lavorazione
local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtCopyMachining( sNewName, sName)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
else
-- riporto il sovramateriale originale e tolgo i passi
EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset)
EgtSetMachiningParam( MCH_MP.STEP, 0)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
end
end
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_YM
if vtN:getY() > 100 * GEO.EPS_ZERO then
nSCC = MCH_SCC.ADIR_YP
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchVId, false)
return false, sErr
-- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto
-- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela)
if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bFirstTrim and
( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then
-- se non da sotto, inserisco lavorazione finitura angolo
--if nSide ~= -1 then
sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchVId = EgtAddMachining( sName, sMilling)
if not nMchVId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- calcolo massima elevazione
local _, _, _, _, _, _, dWidth = EgtSurfTmFacetOppositeSide( Proc.Id, 0, EgtIf( bHead, X_AX(), - X_AX()), GDB_ID.ROOT)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFirstFacet}})
-- setto inversione e lato lavoro per lavorare sinistro
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.WORKSIDE, 1)
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
EgtSetMachiningParam( MCH_MP.STEP, 0)
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1))
-- imposto tipo uso faccia
local nFaceUse = MCH_MILL_FU.PARAL_DOWN
if nSide ~= 1 then
nFaceUse = EgtIf( vtN:getY() > 0.1, MCH_MILL_FU.PARAL_FRONT, MCH_MILL_FU.PARAL_BACK)
end
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_YM
if vtN:getY() > 100 * GEO.EPS_ZERO then
nSCC = MCH_SCC.ADIR_YP
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchVId, false)
return false, sErr
end
end
end
-- aggiorno ingombro testa o coda per presa
if nSide == 0 then
if nSide ~= 1 then
if bHead then
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dCurrOvmH - Proc.Box:getMin():getX())
else
BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Solid:getMin():getX())
end
else
if bHead then
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dCurrOvmH - Proc.Box:getMax():getX())
else
BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Solid:getMin():getX())
end
end
-- aggiorno ingombro testa o coda per presa
--if nSide == 0 then
-- if bHead then
-- BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dCurrOvmH - Proc.Box:getMin():getX())
-- else
-- BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Solid:getMin():getX())
-- end
--end
return true
end