diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 3bc2188..43ce1c7 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -69,10 +69,15 @@ local Q_ANTISPLINT_TYPE = 0 -- i local Q_BLADE_ON_ALONG_FACE = 0 -- i -- variabile smussi -local bMadeChamfer +local _bMadeChamfer +local _nChamfer, _dDepthCham, _sErrCham, _bForceUseBlade -- Settaggi interni -local bTrySidePocketAtFirst = true +local _bTrySidePocketAtFirst = true +local _nPhase, _nRawId, _nPartId, _dOvmHead +local _b3Raw, _b3Solid +local _nAddGrpId + --------------------------------------------------------------------- -- Riconoscimento della feature @@ -145,19 +150,20 @@ end --------------------------------------------------------------------- local function EvaluateQParam( Proc) + + local sErr -- verifico che lo smusso sia richiesto local nChamfer = 0 - local dDepth = Q_DEPTH_CHAMFER - if dDepth > 0 then + if Q_DEPTH_CHAMFER > 0 then nChamfer = 1 end -- verifico se posso fare solo lo smusso if Q_ONLY_CHAMFER == 1 then - if dDepth > 0 then + if Q_DEPTH_CHAMFER > 0 then nChamfer = nChamfer + 1 -- altrimenti se non ho l'affondamento esco else - local sErr = 'Error : no chamfer depth' + sErr = 'Error : no chamfer depth' EgtOutLog( sErr) return -1, dDepth, sErr end @@ -176,6 +182,78 @@ local function EvaluateQParam( Proc) return nChamfer, dDepth, sErr, bForceUseBlade end +--------------------------------------------------------------------- +local function InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) + + if not Proc then + return false, 'Error : Proc is missing' + end + + -- setto a nil la variabile smussi + _bMadeChamfer = nil + _nPhase = nPhase + _nRawId = nRawId + _nPartId = nPartId + _dOvmHead = dOvmHead + + if _nRawId then + -- recupero l'ingombro del grezzo di appartenenza + _b3Raw = EgtGetRawPartBBox( _nRawId) + end + + if not _nPartId then + _nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) + end + + if _nPartId then + -- recupero gruppo per geometria addizionale + _nAddGrpId = BL.GetAddGroup( _nPartId) + -- recupero l'ingombro della trave + _b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( _nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + else + local sErr = 'Error : part ID not found' + EgtOutLog( sErr) + return false, sErr + end + + if not _b3Solid then + local sErr = 'Error : part box not found' + EgtOutLog( sErr) + return false, sErr + end + + if not _nAddGrpId then + local sErr = 'Error : missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + + -- leggo i valori dei parametri Q + AssignQValues( Proc) + -- verifico se sono presenti i parametri Q per la profondità smusso e + -- per eseguire in esclusiva solo lo smusso + _nChamfer, _dDepthCham, _sErrCham, _bForceUseBlade = EvaluateQParam( Proc) + + return true, '' +end + +--------------------------------------------------------------------- +local function GetValidFacetAdjacencies( nSurfId, nFacet) + local vValidAdj + local vFacAdj = EgtSurfTmFacetAdjacencies( nSurfId, nFacet)[1] + + if vFacAdj then + vValidAdj = {} + for j = 1, #vFacAdj do + if vFacAdj[j] >= 0 then + table.insert(vValidAdj, vFacAdj[j]) + end + end + end + + return vValidAdj +end + --------------------------------------------------------------------- local function TestElleShape3( Proc, bNotProc) -- se non passat il Proc vero e proprio @@ -193,15 +271,9 @@ local function TestElleShape3( Proc, bNotProc) -- determino se L con una faccia terminale o U con tre facce local bIsL = true for i = 1, 3 do - local vFacAdj = EgtSurfTmFacetAdjacencies( nProcId, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end - if nCount == 1 then + -- conto le facce adiacenti (solo quelle valide) + local vFacAdj = GetValidFacetAdjacencies( nProcId, i - 1) + if #vFacAdj == 1 then bIsL = false break end @@ -218,19 +290,13 @@ local function TestElleShape4( Proc) local dMinArea3 = GEO.INFINITO * GEO.INFINITO local dMaxArea2 = 0 for i = 1, 4 do - local vFacAdj = EgtSurfTmFacetAdjacencies( Proc.Id, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end + -- conto le facce adiacenti (solo quelle valide) + local vFacAdj = GetValidFacetAdjacencies( Proc.Id, i - 1) local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, i - 1, GDB_ID.ROOT) local dArea = dH * dV - if nCount == 2 then + if #vFacAdj == 2 then dMaxArea2 = max( dMaxArea2, dArea) - elseif nCount == 3 then + elseif #vFacAdj == 3 then dMinArea3 = min( dMinArea3, dArea) nFac3Adj = nFac3Adj + 1 end @@ -375,15 +441,12 @@ local function VerifyBHSideMill( Proc, bMasterIsU, bMasterIsL, bSinglePart, bPre -- verifico se due facce o L con una o due facce di terminazione bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) end - -- recupero l'ingombro della trave - local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) -- verifico se la funzione è lanciata da IsTailFeature o Classify if bSinglePart == nil then -- se lunghezza non richiede spezzatura setto la variabile bSinglePart per non fare con fresa BH -- perchè deve avere almeno 2 facce if not( ( Proc.Box:getDimX() > BD.LONGCUT_MAXLEN) or - ( Proc.Box:getDimX() > 0.8 * b3Solid:getDimX() and Proc.Box:getDimX() > BD.LONGCUT_ENDLEN)) then + ( Proc.Box:getDimX() > 0.8 * _b3Solid:getDimX() and Proc.Box:getDimX() > BD.LONGCUT_ENDLEN)) then bSinglePart = true end end @@ -405,7 +468,7 @@ local function VerifyBHSideMill( Proc, bMasterIsU, bMasterIsL, bSinglePart, bPre -- se forma a U o L verifico che -- se U e lunghezza non richiede spezzatura - if ( bIsU or bIsL or ( Proc.Fct == 1 and not bSinglePart) ) and Proc.Box:getDimX() <= BD.LONGCUT_MAXLEN then + if ( bIsU or bIsL or ( Proc.Fct == 1 and not bSinglePart) ) and Proc.Box:getDimX() <= BD.LONGCUT_MAXLEN then -- se faccia singola di un passo multiplo e risultato precedente non applicato, riporto il risultato del passo precedente if ( bIsU or bIsL or ( Proc.Fct == 1 and not bSinglePart) ) and bPrevBhSideMill ~= nil and not bPrevBhSideMill then return false @@ -426,11 +489,11 @@ local function VerifyBHSideMill( Proc, bMasterIsU, bMasterIsL, bSinglePart, bPre end end -- verifico se la feature è abbastanza vicino a testa/coda da permettere la lavorazione con questo utensile - if b3Solid then + if _b3Solid then local dMinXF = Proc.Box:getMin():getX() local dMaxXF = Proc.Box:getMax():getX() - local dMinT = b3Solid:getMin():getX() - local dMaxT = b3Solid:getMax():getX() + local dMinT = _b3Solid:getMin():getX() + local dMaxT = _b3Solid:getMax():getX() -- determino se è più vicino alla testa o al bordo (con offset per evitare problemi a metà) bHeadDir = ( dMaxT - dMinXF) < ( dMaxXF - dMinT) + 50 bHead = bHeadDir @@ -452,11 +515,9 @@ local function VerifyBHSideMill( Proc, bMasterIsU, bMasterIsL, bSinglePart, bPre end --------------------------------------------------------------------- -local function GetTunnelDimension( Proc, nPartId) +local function GetTunnelDimension( Proc) -- sono necessarie almeno due facce if Proc.Fct < 2 then return 0, 0, 0 end - -- recupero l'ingombro della trave - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) -- recupero centro e normale delle facce local ptC = {} local vtN = {} @@ -476,20 +537,14 @@ local function GetTunnelDimension( Proc, nPartId) end end -- ottengo il boundingBox e prendo le dimensioni lungo la direzione (Z locale) che rappresenta la profondità della fessura - local frFc = Frame3d( ptC[1], vtOrtho) ; + local frFc = Frame3d( ptC[1], vtOrtho) local b3BoxLoc = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frFc) local dDepth = b3BoxLoc:getDimZ() - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - EgtOutLog( 'Error : missing AddGroup') - return 0, 0, 0 - end -- centro del bounding box locale local ptCen = b3BoxLoc:getCenter() ptCen:toGlob( frFc) -- creo superficie intermedia - local nSurfInt = EgtSurfTmPlaneInBBox( nAddGrpId, ptCen, vtOrtho, b3Solid, GDB_ID.ROOT) + local nSurfInt = EgtSurfTmPlaneInBBox( _nAddGrpId, ptCen, vtOrtho, _b3Solid, GDB_ID.ROOT) if not nSurfInt then return 0, 0, 0 end -- ritaglio la superficie con le facce della fessura for i = 1, Proc.Fct do @@ -510,8 +565,8 @@ end --------------------------------------------------------------------- local function GetFaceAdj( Proc, nFacInd, dH, dV) - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] + -- Recupero le facce adiacenti alla principale (solo quelle esistenti) + local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' return -1, sErr @@ -524,14 +579,12 @@ local function GetFaceAdj( Proc, nFacInd, dH, dV) -- Cerco una faccia adiacente alla principale sul lato lungo local nFacAdj for i = 1, #vAdj do - if vAdj[i] >= 0 then - local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) - local dLen = dist( ptP1, ptP2) - if dLen > 0.5 * dH then - nFacAdj = vAdj[i] - EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 4) - break - end + local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local dLen = dist( ptP1, ptP2) + if dLen > 0.5 * dH then + nFacAdj = vAdj[i] + EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 4) + break end end if not nFacAdj then @@ -561,6 +614,10 @@ end --------------------------------------------------------------------- -- Verifica se feature di testa function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) + if not InitGlob( Proc) then + return false + end + -- se una sola faccia if Proc.Fct == 1 then local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -573,22 +630,19 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) return false end -- la sua lunghezza non deve superare il massimo e 60% della lunghezza della trave - if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 *b3Raw:getDimX()) then + if Proc.Box:getDimX() > min( BD.MAX_LEN_HTFEA, 0.6 * b3Raw:getDimX()) then return false end - -- recupero identificativo del pezzo - local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) -- se una o due facce e interessa veramente la testa, allora di testa if Proc.Fct <= 2 then - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if Proc.Box:getMax():getX() > b3Solid:getMax():getX() - 1. then + if Proc.Box:getMax():getX() > _b3Solid:getMax():getX() - 1. then return true - elseif Proc.Box:getMax():getX() < b3Solid:getMax():getX() - 5. then + elseif Proc.Box:getMax():getX() < _b3Solid:getMax():getX() - 5. then return false end end -- deve avere la normale principale diretta verso la testa - local nFacInd, dElev = BL.GetFaceWithMostAdj( Proc.Id, nPartId) + local nFacInd, dElev = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) if vtN and vtN:getX() < 0.499 then return false @@ -606,6 +660,10 @@ end --------------------------------------------------------------------- -- Verifica se feature di coda function ProcessLapJoint.IsTailFeature( Proc, b3Raw) + if not InitGlob( Proc) then + return false + end + -- se una sola faccia if Proc.Fct == 1 then local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -613,19 +671,14 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) return true end end - -- in base al tipo di feature leggo i valori dei parametri Q - AssignQValues( Proc) -- se può essere fatto con utensile tipo lama local bUseBHSideMill, bHead, bHeadDir = VerifyBHSideMill( Proc) if bUseBHSideMill then Proc.HeadDir = bHeadDir return not bHead end - -- recupero box del pezzo - local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) -- verifico se è in coda - local dEndDist = Proc.Box:getMin():getX() - b3Solid:getMin():getX() + local dEndDist = Proc.Box:getMin():getX() - _b3Solid:getMin():getX() if dEndDist > BD.MAX_DIST_HTFEA then return false end @@ -635,14 +688,14 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) end -- se una o due facce e interessa veramente la coda, allora di coda if Proc.Fct <= 2 then - if Proc.Box:getMin():getX() < b3Solid:getMin():getX() + 1. then + if Proc.Box:getMin():getX() < _b3Solid:getMin():getX() + 1. then return true - elseif Proc.Box:getMin():getX() > b3Solid:getMin():getX() + 5. then + elseif Proc.Box:getMin():getX() > _b3Solid:getMin():getX() + 5. then return false end end -- deve avere la normale principale diretta verso la coda (oppure tunnel) - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) if vtN and vtN:getZ() < BD.NZ_MINA and nFacInd2 then ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) @@ -659,6 +712,10 @@ end --------------------------------------------------------------------- -- Classificazione della feature function ProcessLapJoint.Classify( Proc, b3Raw) + if not InitGlob( Proc) then + return false + end + -- se 1 faccia if Proc.Fct == 1 then -- dati della faccia @@ -687,8 +744,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw) local bClosedOrthoFaces local nDeletedFace -- 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) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bClosedOrthoFaces = nFacInd2 @@ -698,19 +754,14 @@ function ProcessLapJoint.Classify( Proc, b3Raw) end -- se è una feature scanalatura (con 5 facce) e non è stata riconosciuta come fessura, eseguo altre verifiche if Proc.Prc == 16 and Proc.Fct == 5 and not bClosedOrthoFaces then - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - return false - end -- dalla copia della superfice, ciclo eliminando una faccia per volta per verificare se trova fessura for i = 1, Proc.Fct do - local nNewProc = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + local nNewProc = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL -- elimino una faccia nDeletedFace = i - 1 if EgtSurfTmRemoveFacet( nNewProc, nDeletedFace) then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( nNewProc, nPartId) + nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( nNewProc, _nPartId) if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bClosedOrthoFaces = nFacInd2 @@ -739,7 +790,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw) -- 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) + local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc) EgtErase( nSurfInt) -- verifico se può essere fatto con svuotatura if VerifyPocket( Proc, dDimMin) then @@ -776,10 +827,8 @@ function ProcessLapJoint.Classify( Proc, b3Raw) end -- verifico se la faccia principale è sottosquadra, ha forma L ed esiste la faccia adiacente elseif vtN:getZ() < -0.2589 and bIsL and nFaceAdj >= 0 then - -- box del pezzo - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - -- se il numero di facce > 2 o il box della feature supera una certa distanza dalle teste allora controllo la z della faccia ausiiaria - if Proc.Fct > 2 or ( Proc.Box:getMax():getX() < b3Solid:getMin():getX() - 150) or ( Proc.Box:getMin():getX() > b3Solid:getMax():getX() + 150) then + -- se il numero di facce > 2 o il box della feature supera una certa distanza dalle teste allora controllo la z della faccia ausiliaria + if Proc.Fct > 2 or ( Proc.Box:getMax():getX() < _b3Solid:getMin():getX() - 150) or ( Proc.Box:getMin():getX() > _b3Solid:getMax():getX() + 150) then local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFaceAdj, GDB_ID.ROOT) bDown = ( vtN2:getZ() < BD.NZ_MINB) end @@ -793,16 +842,8 @@ end --------------------------------------------------------------------- -- Lavorazione con fresa --------------------------------------------------------------------- -local function MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) - -- recupero l'ingombro del grezzo di appartenenza - local b3Raw = EgtGetRawPartBBox( nRawId) - -- recupero l'ingombro della trave - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not b3Solid then - local sErr = 'Error : part box not found' - EgtOutLog( sErr) - return false, sErr - end +local function MakeOneFaceByMill( Proc) + -- verifico il numero di facce della tacca assert( ( Proc.Fct == 1), 'Error : MakeOneFaceByMill in LapJoint with ' .. tostring( Proc.Fct) .. ' faces') -- dati della faccia @@ -852,14 +893,14 @@ local function MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) return false, sErr end -- eventuale segnalazione ingombro di testa o coda - local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) - if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * _b3Raw:getDimZ()) + if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < _b3Raw:getMin():getZ() + dMinHIng then if Proc.Head then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - BL.UpdateHCING( nRawId, dOffs) + local dOffs = _b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( _nRawId, dOffs) elseif Proc.Tail then - local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - BL.UpdateTCING( nRawId, dOffs) + local dOffs = Proc.Box:getMax():getX() - _b3Solid:getMin():getX() + BL.UpdateTCING( _nRawId, dOffs) end end return true @@ -905,23 +946,13 @@ local function DoMill( Proc, sMilling, offset, nFacInd, nFac2Ind, vtN) end --------------------------------------------------------------------- -local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) - -- recupero l'ingombro del grezzo di appartenenza - local b3Raw = EgtGetRawPartBBox( nRawId) - -- recupero l'ingombro della trave - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not b3Solid then - local sErr = 'Error : part box not found' - EgtOutLog( sErr) - return false, sErr - end +local function MakeTwoFacesByMill( Proc, bDownHead) + -- verifico il numero di facce della tacca assert( ( Proc.Fct == 2), 'Error : MakeTwoFacesByMill in LapJoint with ' .. tostring( Proc.Fct) .. ' faces') - -- recupero il parametro Q per uso fresa - local nUseRM = Q_USE_MILL -- recupero la lavorazione local sMilling - if nUseRM and nUseRM == 1 then + if Q_USE_MILL and Q_USE_MILL == 1 then sMilling = ML.FindMilling( 'LongSmallCut' .. EgtIf( bDownHead, '_H2', '')) else sMilling = ML.FindMilling( 'BirdsMouth' .. EgtIf( bDownHead, '_H2', '')) @@ -974,7 +1005,7 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) -- altrimenti, scelgo quella con la normale più perpendicolare all'asse trave (se uguali, quella verso X+) else if abs( abs( vtN[1]:getX()) - abs( vtN[2]:getX())) < GEO.EPS_SMALL then - if ptM:getX() > b3Raw:getCenter():getX() then + if ptM:getX() > _b3Raw:getCenter():getX() then nFacInd = EgtIf( vtN[1]:getX() > vtN[2]:getX(), 0, 1) else nFacInd = EgtIf( vtN[1]:getX() < vtN[2]:getX(), 0, 1) @@ -992,46 +1023,43 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) local sName local nMchFId local nFaceUse + local bOk, sErr -- se forzato uso fresa controllo se posso fare in una o più passate - if nUseRM and nUseRM == 1 then - DoMill( Proc, sMilling, dTDiam/2, nFacInd, nOthInd, vtN) + if Q_USE_MILL and Q_USE_MILL == 1 then + bOk, sErr = DoMill( Proc, sMilling, dTDiam/2, nFacInd, nOthInd, vtN) + + if not bOk then return bOk, sErr end end - DoMill( Proc, sMilling, 0, nFacInd, nOthInd, vtN) + bOk, sErr = DoMill( Proc, sMilling, 0, nFacInd, nOthInd, vtN) + if not bOk then return bOk, sErr end -- eventuale segnalazione ingombro di testa o coda - local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) - if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * _b3Raw:getDimZ()) + if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < _b3Raw:getMin():getZ() + dMinHIng then if Proc.Head then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - BL.UpdateHCING( nRawId, dOffs) + local dOffs = _b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( _nRawId, dOffs) elseif Proc.Tail then - local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - BL.UpdateTCING( nRawId, dOffs) - elseif Proc.Box:getCenter():getX() > b3Solid:getCenter():getX() then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - local dDist = b3Solid:getMax():getX() - Proc.Box:getMax():getX() + local dOffs = Proc.Box:getMax():getX() - _b3Solid:getMin():getX() + BL.UpdateTCING( _nRawId, dOffs) + elseif Proc.Box:getCenter():getX() > _b3Solid:getCenter():getX() then + local dOffs = _b3Solid:getMax():getX() - Proc.Box:getMin():getX() + local dDist = _b3Solid:getMax():getX() - Proc.Box:getMax():getX() -- sempre concavo aumento la distanza (rimane una punta...) dDist = dDist + 10 - BL.UpdateHCING( nRawId, dOffs, dDist) + BL.UpdateHCING( _nRawId, dOffs, dDist) end end return true end --------------------------------------------------------------------- -local function MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer) +local function MakePreCuts( Proc) -- se interessa l'intera sezione della trave, necessaria sgrossatura - if nChamfer < 2 and Proc.Box:getDimY() > 0.9 * b3Raw:getDimY() and Proc.Box:getDimZ() > 0.9 * b3Raw:getDimZ() then - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error : missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end + if _nChamfer < 2 and Proc.Box:getDimY() > 0.9 * _b3Raw:getDimY() and Proc.Box:getDimZ() > 0.9 * _b3Raw:getDimZ() then -- aggiungo sgrossatura e la lavoro - local AddId = EgtSurfTmConvexHullInBBox( nAddGrpId, Proc.Id, b3Raw, GDB_RT.GLOB) + local AddId = EgtSurfTmConvexHullInBBox( _nAddGrpId, Proc.Id, _b3Raw, GDB_RT.GLOB) if AddId then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) -- applico lavorazione @@ -1039,9 +1067,9 @@ local function MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nCha Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} local nCutFacet = EgtSurfTmFacetCount( AddId) if nCutFacet == 1 then - return Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) + return Cut.Make( CutProc, _nPhase, _nRawId, _nPartId, _dOvmHead) elseif nCutFacet == 2 then - return DoubleCut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) + return DoubleCut.Make( CutProc, _nPhase, _nRawId, _nPartId, _dOvmHead) end end end @@ -1304,7 +1332,7 @@ local function TestPoints( nPathInt, i, pPiniAxis, pPendAxis, b3SolidMinAxis, b3 end --------------------------------------------------------------------- -local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) +local function SetOpenSide( nPathInt, vtOrtho, nStartPoint) -- fondo tra loro le curve compatibili EgtMergeCurvesInCurveCompo( nPathInt) @@ -1320,22 +1348,22 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) -- Se normale lungo la Z considero il box in X e Y if abs(vtOrtho:getZ()) > 0.999 then -- se corrisponde a X - if TestPoints(nPathInt, i, pPini:getX(), pPend:getX(), b3Solid:getMin():getX(), b3Solid:getMax():getX()) then + if TestPoints(nPathInt, i, pPini:getX(), pPend:getX(), _b3Solid:getMin():getX(), _b3Solid:getMax():getX()) then pLastPIni = pPini pLastPEnd = pPend -- altrimenti se corrisponde a Y - elseif TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), b3Solid:getMin():getY(), b3Solid:getMax():getY()) then + elseif TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then pLastPIni = pPini pLastPEnd = pPend end -- altrimenti se normale lungo la Y considero il box in X e Z elseif abs(vtOrtho:getZ()) < 0.001 and abs(vtOrtho:getY()) > 0.999 then -- se corrisponde a X - if TestPoints(nPathInt, i, pPini:getX(), pPend:getX(), b3Solid:getMin():getX(), b3Solid:getMax():getX()) then + if TestPoints(nPathInt, i, pPini:getX(), pPend:getX(), _b3Solid:getMin():getX(), _b3Solid:getMax():getX()) then pLastPIni = pPini pLastPEnd = pPend -- altrimenti se corrisponde a Z - elseif TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), b3Solid:getMin():getZ(), b3Solid:getMax():getZ()) then + elseif TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then pLastPIni = pPini pLastPEnd = pPend end @@ -1343,11 +1371,11 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) -- altrimenti se normale lungo la X considero il box in Y e Z elseif abs(vtOrtho:getZ()) < 0.001 and abs(vtOrtho:getX()) > 0.999 then -- se corrisponde a Y - if TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), b3Solid:getMin():getY(), b3Solid:getMax():getY()) then + if TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then pLastPIni = pPini pLastPEnd = pPend -- altrimenti se corrisponde a Z - elseif TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), b3Solid:getMin():getZ(), b3Solid:getMax():getZ()) then + elseif TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then pLastPIni = pPini pLastPEnd = pPend end @@ -1355,7 +1383,7 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) elseif abs(vtOrtho:getZ()) < 0.001 then if abs(vtOrtho:getY()) > 0.75 then -- se corrisponde a Z - if TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), b3Solid:getMin():getZ(), b3Solid:getMax():getZ()) then + if TestPoints(nPathInt, i, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then pLastPIni = pPini pLastPEnd = pPend end @@ -1364,7 +1392,7 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) elseif abs(vtOrtho:getY()) < 0.001 then if abs(vtOrtho:getZ()) > 0.75 then -- se corrisponde a Y - if TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), b3Solid:getMin():getY(), b3Solid:getMax():getY()) then + if TestPoints(nPathInt, i, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then pLastPIni = pPini pLastPEnd = pPend end @@ -1391,8 +1419,7 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, nStartPoint) end --------------------------------------------------------------------- -local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiam, bMillDown, bDoubleSide) +local function MakeRoundCleanCorner( Proc, nFacInd, dDiam, bMillDown, bDoubleSide) -- recupero la lavorazione senza considerare l'elevazione local sMilling = ML.FindMilling( 'SmallToolContour' .. EgtIf( bMillDown and not bDoubleSide, '_H2', '')) @@ -1473,7 +1500,7 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, -- se il punto finale corrisponde con il punto utilizzato in precedenza, uso l'altro local ptApPoint = EgtIf( dist( tFacAdj[i][nIdEndPoint], ptP1) < 10 * GEO.EPS_SMALL, ptP2, ptP1) -- prima linea - local nAuxId = EgtLine( nAddGrpId, ptApPoint, tFacAdj[i][nIdEndPoint], GDB_RT.GLOB) + local nAuxId = EgtLine( _nAddGrpId, ptApPoint, tFacAdj[i][nIdEndPoint], GDB_RT.GLOB) -- calcolo arretramento local dTrimDist = dLen1 - dMinDist -- se arretramento valido @@ -1484,7 +1511,7 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, -- se il punto finale corrisponde con il punto comune, uso l'altro ptApPoint = EgtIf( dist( tFacAdj[i][nIdEndPoint], ptP1x) < 10 * GEO.EPS_SMALL, ptP2x, ptP1x) -- seconda linea - nAuxId = EgtLine( nAddGrpId, tFacAdj[i][nIdEndPoint], ptApPoint, GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[i][nIdEndPoint], ptApPoint, GDB_RT.GLOB) -- calcolo arretramento dTrimDist = dLen2 - dMinDist -- se arretramento valido @@ -1495,7 +1522,7 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, -- trasformo in percorso local AuxId if #pAuxId > 0 then - AuxId = EgtCurveCompo( nAddGrpId, pAuxId, true) + AuxId = EgtCurveCompo( _nAddGrpId, pAuxId, true) end -- deve esserci il percorso if not AuxId then @@ -1521,7 +1548,7 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, if AreSameOrOppositeVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) else @@ -1569,9 +1596,8 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, end --------------------------------------------------------------------- -local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiam, nFunction, bMillDown, - bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, +local function MakeRoundCleanContour( Proc, nFacInd, dDiam, nFunction, bMillDown, + bDoubleSide, vtOrtho, nPathInt, nSurfInt, dDepth, bOneShot) -- recupero la lavorazione senza considerare l'elevazione perché viene calcolata l'elevazione utile @@ -1638,7 +1664,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- distanza di sicurezza per evitare collisioni dCollSic = CalcCollisionSafety( vtN1) -- elevazione massima della faccia - dMaxElev = BL.GetFaceElevation( Proc.Id, nFacInd, nPartId) + dMaxElev = BL.GetFaceElevation( Proc.Id, nFacInd, _nPartId) -- ciclo tutta la tabella local tPaths = {} local ptIniPath @@ -1652,7 +1678,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, dAng = tFacAdjMain[i][5] if ( dAng < 0 and dAng >= -90 - 10 * GEO.EPS_SMALL) then -- creo la linea da P1 a P2 - local nAuxId = EgtLine( nAddGrpId, ptP1, ptP2, GDB_RT.GLOB) + local nAuxId = EgtLine( _nAddGrpId, ptP1, ptP2, GDB_RT.GLOB) table.insert( tPaths, nAuxId) -- prendo la lunghezza massima e il punto medio if tFacAdjMain[i][2] > dMaxLen then @@ -1663,7 +1689,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, end end -- costruisco il/i percorso/i - nFirstId, nNumId = EgtCurveCompoByReorder( nAddGrpId, tPaths, ptIniPath, true, GDB_RT.GLOB) + nFirstId, nNumId = EgtCurveCompoByReorder( _nAddGrpId, tPaths, ptIniPath, true, GDB_RT.GLOB) if nFirstId then -- se un solo percorso e chiuso cambio il punto di inizio nell'entitá piú lunga if nNumId == 1 and EgtCurveIsClosed( nFirstId) then @@ -1678,7 +1704,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- alrimenti ho la faccia aggiunta else -- assegno il percorso - nFirstId = EgtCopyGlob( nPathInt, nAddGrpId) + nFirstId = EgtCopyGlob( nPathInt, _nAddGrpId) nNumId = 1 -- distanza di sicurezza per evitare collisioni dCollSic = CalcCollisionSafety( vtOrtho) @@ -1706,7 +1732,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- normale alla faccia aggiunta vtN1 = Vector3d( vtOrtho) -- imposto i lati aperti - SetOpenSide( nFirstId, vtOrtho, b3Solid, nAddGrpId, 2) + SetOpenSide( nFirstId, vtOrtho, 2) end -- se non trovato il percorso, esco @@ -1749,7 +1775,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, if AreSameOrOppositeVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) else @@ -1823,7 +1849,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, if AreSameVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = MCH_SCC.ADIR_YP else @@ -1872,9 +1898,8 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, end --------------------------------------------------------------------- -local function MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiam, nFunction, bMillDown, - bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, +local function MakeRoundCleanCornerOrContour( Proc, nFacInd, dDiam, nFunction, bMillDown, + bDoubleSide, vtOrtho, nPathInt, nSurfInt, dDepth, bOneShot) -- se modalitá pulitura spigoli e lavorazione di lato forzo a fare il contorno @@ -1883,14 +1908,12 @@ local function MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3R end -- se richiesta pulitura del contorno if nFunction == 1 then - return MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiam, nFunction, bMillDown, - bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, + return MakeRoundCleanContour( Proc, nFacInd, dDiam, nFunction, bMillDown, + bDoubleSide, vtOrtho, nPathInt, nSurfInt, dDepth, bOneShot) -- se richiesta pulitura dei soli corner elseif nFunction == 2 then - return MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiam, bMillDown, bDoubleSide) + return MakeRoundCleanCorner( Proc, nFacInd, dDiam, bMillDown, bDoubleSide) -- altri casi non previsti else return true @@ -1898,7 +1921,7 @@ local function MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3R end --------------------------------------------------------------------- -local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam) +local function MakeSharpCleanCorner( Proc, nFacInd, dDiam) local sMyWarn = '' local pAuxId = {} @@ -1964,7 +1987,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI EgtOutLog( sMyWarn) return false, sMyWarn end - nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdIniPoint], tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[nIdLine][nIdIniPoint], tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) table.insert( pAuxId, nAuxId) -- se il punto finale corrisponde con il punto utilizzato in precedenza, uso l'altro if dist( tFacAdj[nIdLine][nIdEndPoint], ptLocP1) < 10 * GEO.EPS_SMALL then @@ -1972,7 +1995,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI else ptApPoint = ptLocP1 end - nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB) dLenTrimExt = dist( tFacAdj[nIdLine][nIdEndPoint], ptApPoint) - (( dDiam/2) + 2) -- se la distanza dei due punti della linea è maggiore dal raggio fresa + delta, trimmo al raggio fresa + delta if dLenTrimExt > 10 * GEO.EPS_SMALL then @@ -1982,7 +2005,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI end table.insert( pAuxId, nAuxId) -- creo linea di ritorno - nAuxId = EgtLine( nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) table.insert( pAuxId, nAuxId) end -- inserisco le ultime tre linee + uscita discostata rispetto all'ingresso @@ -1995,7 +2018,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI else ptApPoint = ptLocP1 end - nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB) dLenTrimExt = dist( tFacAdj[nIdLine][nIdEndPoint], ptApPoint) - (( dDiam/2) + 2) -- se la distanza dei due punti della linea è maggiore dal raggio fresa + delta, trimmo al raggio fresa + delta if dLenTrimExt > 10 * GEO.EPS_SMALL then @@ -2005,18 +2028,18 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI end table.insert( pAuxId, nAuxId) -- creo linea di ritorno - nAuxId = EgtLine( nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB) table.insert( pAuxId, nAuxId) -- piccolo scostamento di 2mm dall'angolo - nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], tFacAdj[nIdLine][nIdEndPoint] + ( 2 * vtExtr), GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], tFacAdj[nIdLine][nIdEndPoint] + ( 2 * vtExtr), GDB_RT.GLOB) table.insert( pAuxId, nAuxId) -- ultima linea di risalita - nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint] + ( 2 * vtExtr), tFacAdj[nIdLine][nIdIniPoint] + ( 2 * vtExtr), GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, tFacAdj[nIdLine][nIdEndPoint] + ( 2 * vtExtr), tFacAdj[nIdLine][nIdIniPoint] + ( 2 * vtExtr), GDB_RT.GLOB) table.insert( pAuxId, nAuxId) end -- trasformo in percorso if #pAuxId > 0 then - AuxId = EgtCurveCompo( nAddGrpId, pAuxId, true) + AuxId = EgtCurveCompo( _nAddGrpId, pAuxId, true) end -- se non c'é il percorso do errore if not AuxId then @@ -2042,7 +2065,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI if AreSameVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = MCH_SCC.ADIR_YP else @@ -2080,7 +2103,7 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI end --------------------------------------------------------------------- -local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam, bSpecialMach) +local function MakeDrillOnCorner( Proc, nFacInd, dDiam, bSpecialMach) local sMyWarn = '' -- ottengo l'angolo dove applicare il foro local dMaxLen, nIdLine, tFacAdj = ChooseCorner( Proc, nFacInd) @@ -2160,14 +2183,14 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, EgtSetGridFrame( Frame3d( tFacAdj[nIdLine][nIdIniPoint], vtExtr)) end -- creo geometria - local AuxId = EgtCircle( nAddGrpId, {0,0,0}, EgtIf( bIsDrilling, dDiamTool/2, ( dDiamTool/2) + 0.1), GDB_RT.GRID) + local AuxId = EgtCircle( _nAddGrpId, {0,0,0}, EgtIf( bIsDrilling, dDiamTool/2, ( dDiamTool/2) + 0.1), GDB_RT.GRID) -- riporto la griglia a globale EgtSetGridFrame() -- calcolo spessore local dDepthBore = dMaxLen if bSpecialMach then -- calcolo l'elevazione - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, tFacAdj[nIdLine][nIdEndPoint], vtExtr) + local dLenIn, dLedOut = BL.GetPointDirDepth( _nPartId, tFacAdj[nIdLine][nIdEndPoint], vtExtr) if dLenIn > 0 then dDepthBore = dLenIn elseif dLedOut then @@ -2230,7 +2253,7 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, end --------------------------------------------------------------------- -local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAddGrpId) +local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho) local nAuxId1, nAuxId2 if nNumIdAux == 1 then -- fondo tra loro le curve compatibili @@ -2296,8 +2319,8 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd -- se non ho trovato da inserirlo aggiungo nuovo elemento in tabella if not bInsTab then table.insert( tPaths, {{( nStartId + i - 1)}, ptP1:getZ()}) - dMaxVal = b3Solid:getMax():getZ() - dMinVal = b3Solid:getMin():getZ() + dMaxVal = _b3Solid:getMax():getZ() + dMinVal = _b3Solid:getMin():getZ() end elseif sDeleteByDir == 'Y' then local bInsTab @@ -2313,8 +2336,8 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd -- se non ho trovato da inserirlo aggiungo nuovo elemento in tabella if not bInsTab then table.insert( tPaths, {{( nStartId + i - 1)}, ptP1:getY()}) - dMaxVal = b3Solid:getMax():getY() - dMinVal = b3Solid:getMin():getY() + dMaxVal = _b3Solid:getMax():getY() + dMinVal = _b3Solid:getMin():getY() end elseif sDeleteByDir == 'X' then local bInsTab @@ -2330,8 +2353,8 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd -- se non ho trovato da inserirlo aggiungo nuovo elemento in tabella if not bInsTab then table.insert( tPaths, {{( nStartId + i - 1)}, ptP1:getX()}) - dMaxVal = b3Solid:getMax():getX() - dMinVal = b3Solid:getMin():getX() + dMaxVal = _b3Solid:getMax():getX() + dMinVal = _b3Solid:getMin():getX() end end end @@ -2380,7 +2403,7 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd end end -- creo concatenamento partendo dal punto iniziale - local nIdLoc = EgtCurveCompoByReorder( nAddGrpId, tPathLoc, pIniLoc, true) + local nIdLoc = EgtCurveCompoByReorder( _nAddGrpId, tPathLoc, pIniLoc, true) if nIdLoc then table.insert( tChamPath, nIdLoc) end @@ -2439,13 +2462,13 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd end --------------------------------------------------------------------- -local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) +local function MakeChamfer( Proc, bIs3Faces, vtOrtho, nSurfInt) - -- Se variabile globale indica che lo smusso è gi stato fatto, esco - if bMadeChamfer then + -- Se variabile globale indica che lo smusso è già stato fatto, esco + if _bMadeChamfer then return 0 end - bMadeChamfer = true + _bMadeChamfer = true -- recupero la lavorazione local sMilling = ML.FindMilling( 'Mark') if not sMilling then @@ -2462,13 +2485,13 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI -- nNumIdAux = 2 -- estraggo i percorsi - nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) + nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, _nAddGrpId) -- se percorso creato estraggo solo i percorsi delle facce interessate, non di testa if nAuxId1 then - nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho, b3Solid, nAddGrpId) + nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho) end else - nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) + nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, _nAddGrpId) if not nNumIdAux then nNumIdAux = 0 end end @@ -2522,8 +2545,8 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI end EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) -- assegno affondamento e offset radiale --- EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - EgtIf( bIs3Faces, (dDepth / 2), 0)) - EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) +-- EgtSetMachiningParam( MCH_MP.DEPTH, _dDepthCham + dExtra - EgtIf( bIs3Faces, (dDepth / 2), 0)) + EgtSetMachiningParam( MCH_MP.DEPTH, _dDepthCham + dExtra) EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) -- se opero su 3 facce e sono al secondo e ultimo percorso inverto la lavorazione -- if bIs3Faces and i == nNumIdAux then @@ -2551,18 +2574,16 @@ local function MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfI end --------------------------------------------------------------------- -local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, - rfFac, dH, dV, dElev, bForceUseBlade, - nBottomFace, nAddGrpId, b3Solid, dSawMaxDepth, sMillingOnSide, +local function MakeByMillAsSaw( Proc, nFacInd, + rfFac, dH, dV, dElev, + nBottomFace, dSawMaxDepth, sMillingOnSide, dSawDiam, dSawThick) local bOrthoFaces local sWarn - -- ingombro del grezzo - local b3Raw = EgtGetRawPartBBox( nRawId) -- ottengo la distanza tra la fine del pezzo e il pezzo successivo - local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5. + local dDistToNextPiece = EgtGetInfo( _nRawId, 'BDST', 'd') or 5. -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId, true) + local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId, true) if not nFacInd1 or nFacInd1 < 0 then if nFacInd1 == -1 then bOrthoFaces = nFacInd2 @@ -2575,10 +2596,10 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, if bOrthoFaces then -- ottengo le dimensioni del tunnel - local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId) + local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc) end - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] + -- Recupero le facce adiacenti alla principale (solo quelle esistenti) + local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' EgtOutLog( sErr) @@ -2589,14 +2610,12 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local nFacAdj local dMaxLen = 0 for i = 1, #vAdj do - if vAdj[i] >= 0 then - local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) - local dLen = dist( ptP1, ptP2) - if dLen > dMaxLen then - nFacAdj = vAdj[i] - dMaxLen = dLen - EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) - end + local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local dLen = dist( ptP1, ptP2) + if dLen > dMaxLen then + nFacAdj = vAdj[i] + dMaxLen = dLen + EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) end end if not nFacAdj then @@ -2643,7 +2662,7 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end end -- Se possibile, lavoro con la lama - if bForceUseBlade then + if _bForceUseBlade then -- Recupero la lavorazione di lama local sCutting = sMillingOnSide -- Calcolo uso faccia @@ -2674,7 +2693,7 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, for i = 1, nStep do local dOffs = ( i - 1) * dStep if vtN:getZ() < BD.NZ_MINA then dOffs = dOffs + dSawThick end - local bOk, sErr, nMchId = Fbs.MakeOne( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, dStartDist, dEndDist, nil, b3Raw) + local bOk, sErr, nMchId = Fbs.MakeOne( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, dStartDist, dEndDist, nil, _b3Raw) if not bOk then return bOk, sErr end -- setto l'elevazione local sNotes = 'MaxElev=' .. EgtNumToString( 0, 1) .. ';' @@ -2691,7 +2710,7 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- in base all'elevazione calcolo l'impronta della lama local dUsedBladeLen = sqrt( ((dSawDiam / 2)*(dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev))) -- controllo direzione taglio e se il minimo della feature sborda in coda - if abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then + if abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then -- do avviso che la lama può sbordare nel pezzo successivo sWarn = 'Warning on mill side as blade : Cut machining can damage next piece' EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')') @@ -2701,20 +2720,18 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end --------------------------------------------------------------------- -local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, - rfFac, dH, dV, dElev, bForceUseBlade, +local function MakeByChainOrSaw( Proc, nFacInd, + rfFac, dH, dV, dElev, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, - bOrthoFacesMaster, nBottomFace, nChamfer, nAddGrpId, b3Solid, - dDepthCham, nSurfInt, bIs3Faces) + bOrthoFacesMaster, nBottomFace, + nSurfInt, bIs3Faces) local bOrthoFaces - local sWarn - -- ingombro del grezzo - local b3Raw = EgtGetRawPartBBox( nRawId) + local sWarn -- ottengo la distanza tra la fine del pezzo e il pezzo successivo - local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5.4 + local dDistToNextPiece = EgtGetInfo( _nRawId, 'BDST', 'd') or 5.4 if bIs3Faces then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId, bIs3Faces) + local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId, bIs3Faces) if not nFacInd1 or nFacInd1 < 0 then if nFacInd1 == -1 then bOrthoFaces = nFacInd2 @@ -2730,16 +2747,16 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, if bOrthoFaces then -- ottengo le dimensioni del tunnel - dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId) + dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc) -- verifico la direzione -- se devo inserire il chamfer - if nChamfer > 0 then - local nOk, sErr = MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if _nChamfer > 0 then + local nOk, sErr = MakeChamfer( Proc, bIs3Faces, vtOrtho, nSurfInt) if nOk < 0 then return false, sErr end end end - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] + -- Recupero le facce adiacenti alla principale (solo quelle esistenti) + local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' EgtOutLog( sErr) @@ -2750,7 +2767,6 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local nFacAdj local dMaxLen = 0 for i = 1, #vAdj do - if vAdj[i] >= 0 then local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) local dLen = dist( ptP1, ptP2) if dLen > dMaxLen then @@ -2758,7 +2774,6 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, dMaxLen = dLen EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) end - end end if not nFacAdj then local sErr = 'Error : long adjacent face not found' @@ -2816,12 +2831,12 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end -- se lavorazione sulle teste e altezza trave supera il limite ( che causa collisione con la forcella) e direzione taglio lungo la Z -- e limite profondità BeamData è maggiore del taglio massimo lama, assegno il massimo affondamento pari al limite profondità del BeamData - if bOpenStart and bOpenEnd and bForceUseBlade and ( Proc.Head or Proc.Tail) and abs(rfFac:getVersY():getY()) > 0.866 and - b3Solid:getDimZ() > BD.MIN_DIM_HBEAM and dSawMaxDepth > BD.MAX_DIM_HTCUT_HBEAM then + if bOpenStart and bOpenEnd and _bForceUseBlade and ( Proc.Head or Proc.Tail) and abs(rfFac:getVersY():getY()) > 0.866 and + _b3Solid:getDimZ() > BD.MIN_DIM_HBEAM and dSawMaxDepth > BD.MAX_DIM_HTCUT_HBEAM then dSawMaxDepth = BD.MAX_DIM_HTCUT_HBEAM end -- Se entrambi gli estremi sono aperti e possibile, lavoro con la lama - if bOpenStart and bOpenEnd and bForceUseBlade and dElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then + if bOpenStart and bOpenEnd and _bForceUseBlade and dElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then -- Recupero la lavorazione di lama local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then @@ -2854,13 +2869,13 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end for i = 1, nStep do local dOffs = ( i - 1) * dStep - local bOk, sErr = Fbs.MakeOne( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, 0, 0, nil, b3Raw) + local bOk, sErr = Fbs.MakeOne( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, 0, 0, nil, _b3Raw) if not bOk then return bOk, sErr end end -- in base all'elevazione calcolo l'impronta della lama local dUsedBladeLen = sqrt( ((dSawDiam / 2)*(dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev))) -- controllo direzione taglio e se il minimo della feature sborda in coda - if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then + if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then -- do avviso che la lama può sbordare nel pezzo successivo sWarn = 'Warning on saw cut : Cut machining can damage next piece' EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')') @@ -2923,7 +2938,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- controllo direzione taglio e se il minimo della feature sborda in coda - if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL then + if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL then -- se ho lato partenza aperto e lato uscita chiuso e direzione lato chiuso è negativa, allora controllo uscita lama if bOpenStart and not bOpenEnd and vtNE:getX() < -0.99 and dDistToNextPiece < (dSawWidth / 2) then -- imposto accorciamento iniziale per estremi aperti/chiusi @@ -3059,10 +3074,8 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, EgtOutLog( sWarn) end end - -- recupero massima elevazione - local dMaxElev = Q_MAX_ELEVATION - if dMaxElev and dMaxElev > 10 then - local sNotes = 'MaxElev=' .. EgtNumToString( dMaxElev, 1) .. ';' + if Q_MAX_ELEVATION and Q_MAX_ELEVATION > 10 then + local sNotes = 'MaxElev=' .. EgtNumToString( Q_MAX_ELEVATION, 1) .. ';' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end -- eseguo @@ -3094,7 +3107,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end --------------------------------------------------------------------- -local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw, nFacInd, bReduceDepth, bMillDown) +local function MakeAntiSplintBySaw( Proc, nFacet, vtN, nFacInd, bReduceDepth, bMillDown) -- Recupero la lavorazione di lama local sCutting = ML.FindCutting( 'HeadSide' .. EgtIf( bMillDown, '_H2', '')) if not sCutting then @@ -3144,7 +3157,7 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw, nFacInd, bReduceDe end end -- eseguo il taglio - local bMadeASbyBld, sWarn, nIdMach = Fbs.MakeOne( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, ( -0.5 + dExtraOffs), BD.CUT_SIC, 0, 0, 0, nil, b3Raw) + local bMadeASbyBld, sWarn, nIdMach = Fbs.MakeOne( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, ( -0.5 + dExtraOffs), BD.CUT_SIC, 0, 0, 0, nil, _b3Raw) if bMadeASbyBld then sWarn = nil if abs(dExtraOffs) > 0 then @@ -3155,11 +3168,11 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw, nFacInd, bReduceDe end --------------------------------------------------------------------- -local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRoughTool, sMasterPocket, dPrevFaceElev, tDimAndRef, dAng) +local function MakePocket( Proc, ptPs, tvtN, nFaceRef, sMchFind, nUseRoughTool, sMasterPocket, dPrevFaceElev, tDimAndRef, dAng) -- calcolo l'elevazione dal punto medio local dElev - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, tvtN[2]) + local dLenIn, dLedOut = BL.GetPointDirDepth( _nPartId, ptPs, tvtN[2]) if dLenIn > 0 then dElev = dLenIn elseif dLedOut then @@ -3258,8 +3271,8 @@ local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRo end --------------------------------------------------------------------- -local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBaseFace, nSideFace, ptPs, tDimAndRef, - b3Raw, nDiffWidth, nUseRoughTool, dAng, sPocketing, sTuuidPk, dPrevFaceElev) +local function MachineByMill( Proc, tvtN, nBaseFace, nSideFace, ptPs, tDimAndRef, + nDiffWidth, nUseRoughTool, dAng, sPocketing, sTuuidPk, dPrevFaceElev) local sMchFind = 'Pocket' local dAngLimit = 40 @@ -3279,7 +3292,7 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBas -- se l'angolo dalla verticale si discosta di più dell'angolo limite impostato, utilizzo la svuotatura if cos( dDiffFromSqAng) < cos( dAngLimit) then -- applico la svuotatura - local bOk, sWarn, sTuuidPk, dDiamTool, dElev = MakePocket( Proc, nPartId, ptPs, tvtN, nSideFace, sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng) + local bOk, sWarn, sTuuidPk, dDiamTool, dElev = MakePocket( Proc, ptPs, tvtN, nSideFace, sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng) if not bOk then -- se ho id utensile e diametro è perchè non ha fatto svuotatura perchè la faccia è più stretta del diametro utensile -- e provo ad inserire singola passata di testa @@ -3395,7 +3408,7 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBas EgtSetMachiningParam( MCH_MP.OFFSR, 0) -- calcolo elevazione per allungamenti attacchi con fianchi chiusi local dElev - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, tvtN[2]) + local dLenIn, dLedOut = BL.GetPointDirDepth( _nPartId, ptPs, tvtN[2]) if dLenIn > 0 then dElev = dLenIn elseif dLedOut then @@ -3431,8 +3444,8 @@ end --------------------------------------------------------------------- local function GetUShapeWidth( Proc, nFacInd) - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] + -- Recupero le facce adiacenti alla principale (solo quelle esistenti) + local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) -- se non ho facce adiacenti esco subito if not vAdj or #vAdj == 0 then return nil end -- Normale della faccia @@ -3440,25 +3453,23 @@ local function GetUShapeWidth( Proc, nFacInd) -- Cerco le facce adiacenti alla principale con angolo concavo >= 90 local dWidth = 0 for i = 1, #vAdj do - if vAdj[i] >= 0 then - -- verifico l'angolo tra le facce ( esco se angolo compreso < 90) - local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) - if bAdj and dAng < -90 - 20 * GEO.EPS_ANG_SMALL then return nil end - -- larghezza della faccia ortogonalmente alla adiacente - local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, vAdj[i], 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 - dWidth = max( dWidth, b3Ref:getDimY()) - end + -- verifico l'angolo tra le facce ( esco se angolo compreso < 90) + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + if bAdj and dAng < -90 - 20 * GEO.EPS_ANG_SMALL then return nil end + -- larghezza della faccia ortogonalmente alla adiacente + local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, vAdj[i], 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 + dWidth = max( dWidth, b3Ref:getDimY()) end end return dWidth end --------------------------------------------------------------------- -local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown) +local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster, bMillDown) local nFirstMachId local bOrthoFaces @@ -3471,7 +3482,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha end if bIs3Faces then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId, bIs3Faces) + local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId, bIs3Faces) if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bOrthoFaces = nFacInd2 @@ -3488,15 +3499,15 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- se è un tunnel verifico se è possibile usare la svuotatura if bOrthoFaces then -- ottengo le dimensioni del tunnel - dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId) + dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc) local nPathInt -- se devo inserire il chamfer - if nChamfer > 0 then - local nOk, sErr = MakeChamfer( Proc, bIs3Faces, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if _nChamfer > 0 then + local nOk, sErr = MakeChamfer( Proc, bIs3Faces, vtOrtho, nSurfInt) if nOk < 0 then return -1, sErr end end -- se smusso non è esclusivo - if nChamfer < 2 then + if _nChamfer < 2 then -- ricalcolo se è lavorabile da sotto bMillDown = ( BD.DOWN_HEAD == true) -- verifico se può essere fatto con svuotatura @@ -3514,11 +3525,11 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- 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 - nPathInt = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) + nPathInt = EgtExtractSurfTmLoops( nSurfInt, _nAddGrpId) EgtModifyCurveExtrusion( nPathInt, vtOrtho, GDB_RT.GLOB) -- se ho 3 facce, ciclo sulle entià del percorso per segnare quelle che sono aperte if bIs3Faces then - SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId) + SetOpenSide( nPathInt, vtOrtho) end -- variabili per parametri lavorazione local dMachDepth @@ -3601,7 +3612,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha 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) + 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 @@ -3683,7 +3694,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha 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) + 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 @@ -3717,7 +3728,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- se non completo e U, cerco di lavorare anche la faccia di fondo (con il massimo affondamento possibile) if not bComplete and bIs3Faces then -- recupero la faccia da lavorare - local nFacInd, dFacElev = BL.GetFaceWithMostAdj( Proc.Id, nPartId) + local nFacInd, dFacElev = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) local vtN local bPock3rd = false if nFacInd then @@ -3749,7 +3760,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha 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) + 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 @@ -3794,7 +3805,16 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha end --------------------------------------------------------------------- -local function ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bMillDown, bReduceDepth) +local function FormatWarning( sWarn, sWarn2) + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end + return sWarn +end + +--------------------------------------------------------------------- +local function ManageAntiSplintBySaw( Proc, bIsU, vtN, nFacInd, sWarn, bMillDown, bReduceDepth) local bMadeASbyBld = false local nNumFac = EgtIf( bIsU, 2, 1) @@ -3818,12 +3838,9 @@ local function ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bM local dSawThick = 0 local dMaxDepth = 200 local bAdj, dAng, dExtraOffs, sWarn2, nIdMach - bMadeASbyBld, sWarn2, nIdMach, dSawThick, dMaxDepth, bAdj, dAng, dExtraOffs = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw, nFacInd, bReduceDepth, bMillDown) + bMadeASbyBld, sWarn2, nIdMach, dSawThick, dMaxDepth, bAdj, dAng, dExtraOffs = MakeAntiSplintBySaw( Proc, nFacet, vtN, nFacInd, bReduceDepth, bMillDown) if not bMadeASbyBld then return bMadeASbyBld, false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end + sWarn = FormatWarning(sWarn, sWarn2) -- se antischeggia veramente inserito perchè necessario if nIdMach then -- verifico se da invertire @@ -3894,7 +3911,7 @@ local function ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bM end --------------------------------------------------------------------- -local function MakePathsOnExtremPoints( nAddGrpId, nIdPath, pPaths, dTDiam) +local function MakePathsOnExtremPoints( nIdPath, pPaths, dTDiam) local dLength = 2 if not nIdPath then return pPaths end @@ -3912,20 +3929,20 @@ local function MakePathsOnExtremPoints( nAddGrpId, nIdPath, pPaths, dTDiam) local ptIniP = ptIni local ptEndP = ptIniP + (vtIni * dLength) - local nAuxId = EgtLine( nAddGrpId, ptIniP, ptEndP, GDB_RT.GLOB) + local nAuxId = EgtLine( _nAddGrpId, ptIniP, ptEndP, GDB_RT.GLOB) table.insert( pPaths, { nAuxId, 1, ptIniP}) ptIniP = ptEnd ptEndP = ptEnd - ( vtEnd * dLength) - nAuxId = EgtLine( nAddGrpId, ptIniP, ptEndP, GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, ptIniP, ptEndP, GDB_RT.GLOB) table.insert( pPaths, { nAuxId, 2, ptIniP}) return pPaths end --------------------------------------------------------------------- -local function MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, - bDoubleSide, bOppoSide, sMilling, nPhase, sMyWarn, +local function MakeAntiSplintByMill( Proc, pPaths, nPathInt, vtN1, + bDoubleSide, bOppoSide, sMilling, sMyWarn, dMaxElevMaster, dExtraDepth, dCollSic, dMaxDepth, nFirstMachId) local sMyWarn2 @@ -3964,7 +3981,7 @@ local function MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, if AreSameVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = MCH_SCC.ADIR_YP else @@ -3995,7 +4012,7 @@ local function MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, if AreSameOrOppositeVectorApprox( vtN1, Z_AX()) then nSCC = MCH_SCC.ADIR_YM elseif abs( vtN1:getX()) < 0.1 then - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + nSCC = EgtIf( BL.IsPartFinalPhase( _nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) elseif vtN1:getY() < GEO.EPS_SMALL then nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) else @@ -4017,7 +4034,7 @@ local function MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, local dMachDepth = 0 local dExtraElev = 0 if bDoubleSide then - dExtraElev = BL.GetFaceElevationFromPointDir( Proc.Id, nPartId, pPaths[i][3], EgtIf( bOppoSide, -vtN1, vtN1)) - dMaxElevMaster + dExtraElev = BL.GetFaceElevationFromPointDir( Proc.Id, _nPartId, pPaths[i][3], EgtIf( bOppoSide, -vtN1, vtN1)) - dMaxElevMaster end local dMaxElev = dMaxElevMaster + dExtraElev if ( dMaxElev + BD.CUT_EXTRA + dCollSic) > dMaxDepth then @@ -4067,9 +4084,8 @@ end --------------------------------------------------------------------- -local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, bMillDown, dDiam, bDoubleSide, - vtOrtho, nPathInt, nSurfInt, b3Solid, dDepth, +local function ManageAntiSplintByMill( Proc, nFacInd, bMillDown, dDiam, bDoubleSide, + vtOrtho, nPathInt, nSurfInt, dDepth, bOneShot, nFirstMachId) local sMyWarn = '' @@ -4142,7 +4158,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, dAng = tFacAdjMain[i][5] if ( dAng < 0 and 180 + dAng >= 90 - 10 * GEO.EPS_SMALL) then -- creo la linea da P1 a P2 - nAuxId = EgtLine( nAddGrpId, ptP1, ptP2, GDB_RT.GLOB) + nAuxId = EgtLine( _nAddGrpId, ptP1, ptP2, GDB_RT.GLOB) table.insert( tPaths, nAuxId) -- prendo la lunghezza massima e il puto medio if tFacAdjMain[i][2] > nMaxLen then @@ -4153,7 +4169,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end end -- cotruisco il/i percorso/i - nFirstId, nNumId = EgtCurveCompoByReorder( nAddGrpId, tPaths, ptIniPath, true, GDB_RT.GLOB) + nFirstId, nNumId = EgtCurveCompoByReorder( _nAddGrpId, tPaths, ptIniPath, true, GDB_RT.GLOB) local bOkPath = true for i = 1, nNumId do local nIdPath = nFirstId + i - 1 @@ -4171,14 +4187,14 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, -- creo percorsi antisplint dagli estremi dei percorsi di contorno trovati for i = 1, nNumId do local nIdPath = nFirstId + i - 1 - pPaths = MakePathsOnExtremPoints( nAddGrpId, nIdPath, pPaths, dTDiam) + pPaths = MakePathsOnExtremPoints( nIdPath, pPaths, dTDiam) end end -- alrimenti ho la faccia aggiunta else dCollSic = CalcCollisionSafety( vtOrtho) - nFirstId = EgtCopyGlob( nPathInt, nAddGrpId) + nFirstId = EgtCopyGlob( nPathInt, _nAddGrpId) nNumId = 1 -- calcolo elevazione dalla faccia trasversale aggiunta if bDoubleSide then @@ -4201,19 +4217,19 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end end vtN1 = Vector3d(vtOrtho) - local bOkPath = SetOpenSide( nFirstId, vtOrtho, b3Solid, nAddGrpId, 2) + local bOkPath = SetOpenSide( nFirstId, vtOrtho, 2) -- se non ho un percorso chiuso estraggo i percorsi if bOkPath then -- creo percorsi antisplint dagli estremi dei percorsi di contorno trovati - pPaths = MakePathsOnExtremPoints( nAddGrpId, nFirstId, pPaths, dTDiam) + pPaths = MakePathsOnExtremPoints( nFirstId, pPaths, dTDiam) end EgtErase(nFirstId) end if #pPaths > 0 then - sMyWarn = MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, - bDoubleSide, false, sMilling, nPhase, sMyWarn, + sMyWarn = MakeAntiSplintByMill( Proc, pPaths, nPathInt, vtN1, + bDoubleSide, false, sMilling, sMyWarn, dMaxElevMaster, dExtraDepth, dCollSic, dMaxDepth, nFirstMachId) if bDoubleSide then if bMillDown then @@ -4230,8 +4246,8 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end -- se lavorazione valida if sMilling then - sMyWarn = MakeAntiSplintByMill( Proc, nPartId, pPaths, nPathInt, vtN1, - bDoubleSide, true, sMilling, nPhase, sMyWarn, + sMyWarn = MakeAntiSplintByMill( Proc, pPaths, nPathInt, vtN1, + bDoubleSide, true, sMilling, sMyWarn, dMaxElevMaster, dExtraDepth, dCollSic, dMaxDepth, nFirstMachId) else sMyWarn = 'warning in process ' .. tostring( Proc.Id) .. ' clean corner milling/tool not found in library' @@ -4253,30 +4269,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end --------------------------------------------------------------------- --- funzione di utlilità (disegna l'indice della faccia su ognuna) per --- verificare visivamente quali sono le facce coinvolte nei calcoli ---------------------------------------------------------------------- -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 lay = EgtGroup( EgtGroup( GDB_ID.ROOT), rFrame, GDB_RT.GLOB) - EgtFrame( GDB_ID.ROOT, rFrame, GDB_ID.GLOB) - local idTxt = EgtTextEx( lay, {-4, -5, 0}, 0, tostring( fcIdx), 'Arial', 'S', 10) - EgtSetColor( idTxt, {255, 255, 255, 100}, false) - EgtSetName( idTxt, 'Txt_Surf' .. tostring( SurfId) .. '_Face' .. tostring( fcIdx)) - EgtRelocateGlob( idTxt, GDB_ID.ROOT) - EgtErase( lay) - end -end - ---------------------------------------------------------------------- -local function MakeBySideMill( Proc) +local function MakeBySideMill( Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dToolDiam, bHeadDir) local dH, dV -- se smusso non è esclusivo @@ -4373,51 +4366,9 @@ local function MakeBySideMill( Proc) end --------------------------------------------------------------------- -local function AreFacesOrthogonal( nSurfId, nFacInd, nFacInd2, dCosSideAng) - 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) +local function MakeSpecialThreeFaces( Proc, bIsL) - -- 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 AreAllFacesOrthogonal( nSurfId, dCosSideAng) - -- recupero il numero di facce - local nFacCnt = EgtSurfTmFacetCount( nSurfId) - if not dCosSideAng then - dCosSideAng = -0.09 - end - - local dOrtho = 0 - for i = 0, nFacCnt - 1 do - local fc1 = i - local fc2 = EgtIf( i < nFacCnt - 1, i + 1, 0) - - dOrtho = AreFacesOrthogonal( nSurfId, fc1, fc2, dCosSideAng) - - -- alla prima faccia non ortogonale esco dal ciclo - if dOrtho ~= 0 then break end - end - return dOrtho -end - ---------------------------------------------------------------------- -local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nChamfer) - - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) + 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) @@ -4431,7 +4382,7 @@ local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmH 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) + local bOk, sErr = MakePreCuts( Proc) if not bOk then return false, sErr end end -- Recupero la lavorazione di fresa @@ -4455,90 +4406,40 @@ local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmH if abs( vtN2:getX()) > 0.7 or abs( vtN2:getY()) > 0.7 or abs( vtN2:getZ()) > 0.7 then dCollSic2 = 0 end local sPocketing local nPockFace - -- controllo se tutte le facce sono ortogonali - local dOrtho = AreAllFacesOrthogonal( Proc.Id) - if (dOrtho == 0) then -- tutte ortogonali + sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2) + nPockFace = nFacInd2 + -- se non trova una svuotatura adatta provo ad assegnarla all'altra faccia + if not sPocketing then + 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 + + -- prendo a riferimento la seconda faccia per la svuotatura sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2) - nPockFace = nFacInd2 - -- se non trova una svuotatura adatta provo ad assegnarla all'altra faccia - if not sPocketing then - if (dOrtho == 0) then - -- se ortogonali, faccio uno 'swap' delle 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 - -- prendo a riferimento la seconda faccia per la svuotatura - 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 - - -- provo con contornatura - local dDiamTool = 20 - if bIsL then - local bOk, sWarn - bOk, sWarn, _ = MakeByMill( Proc, 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 - -- tentativo di lavorazione per tacca non aperta (almeno una faccia è overcut) - elseif (dOrtho > 0) then -- overcut (angolo aperto) - - -- inizio con la prima faccia per la svuotatura - nPockFace = nFacInd - sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic) if not sPocketing then local sErr = 'Error : '..sMchFind..' not found in library' EgtOutLog( sErr) return false, sErr end - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] - if not vAdj or #vAdj == 0 then - local sErr = 'Error : main face without adjacencies' - EgtOutLog( sErr) - return false, sErr - end - -- Cerco una faccia adiacente alla principale con angolo > 90 - local nFacAdj - local tDimAndRef = {} - local tvtNx = {} - tvtNx[1] = vtN - tDimAndRef[1] = {dH, dV, rfFac} - for i = 1, #vAdj do - if vAdj[i] >= 0 then - local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) - if bAdj and dAng < 0 and 180 + dAng > 90.1 then - local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vAdj[i], GDB_ID.ROOT) - _, tvtNx[2] = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) - tDimAndRef[2] = {dH2, dV2, rfFac2} - local ptPs = ( ptP1 + ptP2) / 2 - local sMchFind = 'Pocket' - -- applico la svuotatura - local bOk, sWarn, _, _, _ = MakePocket( Proc, nPartId, ptPs, tvtNx, vAdj[i], sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng) - - if not bOk then - EgtOutLog( 'Unable to make Pocket on the oblique face: ' + sWarn) - end - end - end - end + end + + -- provo con contornatura + local dDiamTool = 20 + if bIsL then + local bOk, sWarn + bOk, sWarn, _ = MakeByMill( Proc, 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 @@ -4580,11 +4481,11 @@ local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmH -- 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) + local bOk, sWarn = MakeDrillOnCorner( Proc, 0, 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) + local bOk, sWarn = MakeSharpCleanCorner( Proc, 0, dDiamTool) if not bOk then return false, sWarn end end @@ -4592,30 +4493,628 @@ local function MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmH end --------------------------------------------------------------------- -local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill) +local function MakeByChainsaw( Proc, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace) + -- verifico se posso farlo con la sega-catena + local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifyChainSaw( Proc, dDimMin, dDimMax) + + 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) + else + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK) + end + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nLundIdFace, GDB_ID.ROOT) + -- imposto angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 1)) + EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, vtOrtho)) + -- 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 : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + -- eseguo + if not EgtApplyMachining( true, false) then + if EgtGetOutstrokeInfo() then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 2)) + EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, vtOrtho)) + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + if EgtIsMachiningEmpty() then + _, sWarn = EgtGetMachMgrWarning( 0) + EgtSetOperationMode( nMchFId, false) + return false, sWarn + end + end + end + + return true +end + +--------------------------------------------------------------------- +local function MakeSidePocketings(Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, bSpecialMillOnSide, + nBottomFace, dMaxDepthOnSide, sMillingOnSide, + dToolDiamOnSide, dThickMillOnSide, bSinglePart, bIsU, bIsL, dDiam, bMillDown, bMillUp, sMchFind, sMchFindBackUp) + local bTryWithBlades = true + local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nSurfInt + if bSpecialMillOnSide then + -- eseguo + bOk, sWarn = MakeByMillAsSaw( Proc, nFacInd, + rfFac, dH, dV, dFacElev, bSpecialMillOnSide, + nBottomFace, dMaxDepthOnSide, sMillingOnSide, + dToolDiamOnSide, dThickMillOnSide) + if bOk then + return 1, true, sWarn + end + end + -- se feature 16 o 17 e se forzata lama provo prima con questa e poi con la fresa + if ( Proc.Prc == 16 or Proc.Prc == 17) and _bForceUseBlade then + -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame + if bTryWithBlades and _nChamfer < 2 then + -- anche su macchine con testa da sotto, la sega a catena è solo da sopra + if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then + nFacInd, nFacInd2 = nFacInd2, nFacInd + dFacElev, dFacElev2 = dFacElev2, dFacElev + rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + end + -- eseguo (come 3 faces) + bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nFacInd, + rfFac, dH, dV, dFacElev, + dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, + bOrthoFaces, nBottomFace, + nSurfInt, true) + if not bOk then + -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e + -- se non è possibile allora provo in seguito con lama o segacatena + -- 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) + -- se lavorazione non idonee ( asse della feature troppo inclinato e impossibile lavorare completamente da due parti) + if nOk == -2 then + if not sMchFind then + sMchFind = sMchFindBackUp + end + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr) + return 1, false, sErr + end + elseif nOk < 0 then + return 1, false, sErr + elseif nOk == 0 then + if sStat == 'MNF' then + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr) + return 1, false, sErr + end + else + return 1, bOk, sWarn + end + else + bOk = true + return 1, bOk, sErr + end + else + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr) + return 1, false, sErr + end + end + else + return 1, bOk, sWarn + end + else + -- se devo inserire il chamfer + if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and _nChamfer > 0 then + -- ottengo le dimensioni dello pseudotunnel + local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc) + local nOk, sErr = MakeChamfer( Proc, true, vtOrtho, nSurfInt) + if nOk < 0 then return 1, false, sErr end + end + bOk = true + return 1, bOk, sWarn + end + else + -- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo + -- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa + -- 2021.04.27 esegue antischeggia di lama se forma U o L con feature passante in Y o Z + -- 2021.07.16 Per poter eseguire antischeggia di lama su feature che non sono passanti da faccia a faccia + -- ma che sono su un angolo (coinvolgono 2 facce contigue) è stato modificato il confronto in: + -- esegue antischeggia di lama se forma U o L con feature passante in Y o Z, oppure se feature a furma U e con 3 facce oppore a forma a L e con 2 facce + local bMadeASbyBld = false + local bPassThrou = ( Proc.Box:getDimY() > _b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > _b3Raw:getDimZ() - 1) + local bPassEdge = ((( bIsU and Proc.Fct == 3) or ( bIsL and Proc.Fct == 2)) and bSinglePart and Proc.Box:getDimX() < 0.9 * _b3Raw:getDimX()) + if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then + local bOk + local bSawDown = ( bMillDown and not bMillUp) + bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, vtN, nFacInd, sWarn, bSawDown, true) + if not bOk then return 1, false, sWarn end + end + -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e + -- se non è possibile allora provo in seguito con lama o segacatena + -- 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) + if nOk == -2 then + if not sMchFind then + sMchFind = sMchFindBackUp + end + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr2 = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr2) + return 1, false, sErr2 + end + bTryWithBlades = false + sWarn = sErr + elseif nOk < 0 then + return 1, false, sErr + elseif nOk > 0 then + 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 Q_ANTISPLINT_TYPE == 2 then + local bOk, sWarn2 = ManageAntiSplintByMill( Proc, nFacInd, bMillDown, dDiamTool, bDoubleSide, + vtOrtho, nPathInt, nSurfInt, dDepth, + bOneShot, nFirstMachId) + sWarn = FormatWarning(sWarn, sWarn2) + end + -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola + if Q_CONTOUR_SMALL_TOOL > 0 then + local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown, + bDoubleSide, vtOrtho, nPathInt, nSurfInt, + dDepth, bOneShotm) + if not bOk then return 1, false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + end + end + bOk = true + end + -- 03/09/2020 da conferma di Fabio Squaratti: Per ora solo sulla feature 016: + -- se ha fallito la fresatura (qua sopra) allora di default ( anche se il flag Q della lama è disattivato) prima provo la lama + if Proc.Prc == 16 then + _bForceUseBlade = true + end + -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame + if bTryWithBlades and _nChamfer < 2 then + -- anche su macchine con testa da sotto, la sega a catena è solo da sopra + if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then + nFacInd, nFacInd2 = nFacInd2, nFacInd + dFacElev, dFacElev2 = dFacElev2, dFacElev + rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + end + -- eseguo (non 3 faces) + bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nFacInd, + rfFac, dH, dV, dFacElev, + dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, + bOrthoFaces, nBottomFace, nSurfInt) + if not bOk and sStat == 'MNF' then + _, sPocketing = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, nil, sMchFind) + if sPocketing then + sWarn = '' + else + local sErr2 = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr2) + return 1, false, sErr2 + end + else + -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola + if Q_CONTOUR_SMALL_TOOL > 0 then + local bOk, sWarn2 + bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, 100, Q_CONTOUR_SMALL_TOOL, bMillDown) + if not bOk then return 1, false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + end + return 1, bOk, sWarn + end + -- altrimenti verifico se ho già svuotato dal fianco, se si esco + else + -- se non ho annullato la/le svuotatura/e dal fianco + if nOk ~= -2 then + return 1, bOk, sWarn + end + end + end + + return 0, true, '' +end + +--------------------------------------------------------------------- +local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev) + -- 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)) + -- 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) + local bUseOtherFace + -- se orientata verso il basso e non c'è testa da sotto, verifico l'alternativa + if vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD and nFacInd2 then + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + nFacInd, nFacInd2 = nFacInd2, nFacInd + dFacElev, dFacElev2 = dFacElev2, dFacElev + bUseOtherFace = true + end + -- verifico non sia orientata verso il basso o ci sia una testa dal basso + local bFaceDown = ( vtN:getZ() < BD.NZ_MINA) + if bFaceDown and not BD.DOWN_HEAD then + local sErr = 'Error : LapJoint from bottom impossible' + EgtOutLog( sErr) + return false, sErr + end + -- se forma a L e la componente in X è maggiore di 60° e non in testa allora verifico se posso utilizzare la faccia secondaria + if bIsL and abs( vtN:getX()) > 0.866 and + ( Proc.Box:getMax():getX() < _b3Solid:getMax():getX() - 10 or vtN:getX() < 0) and + ( not Proc.Tail or vtN:getX() > 0) then + -- se non ho scambiato la faccia + if not bUseOtherFace then + if nFacInd2 then + nFacInd, nFacInd2 = nFacInd2, nFacInd + dFacElev, dFacElev2 = dFacElev2, dFacElev + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + -- altrimenti cerco la faccia secondaria per adiacenza alla principale + else + -- Cerco una faccia adiacente alla principale sul lato lungo + local nFacAdj, sErr = GetFaceAdj( Proc, nFacInd, dH, dV) + if nFacAdj < 0 then + EgtOutLog( sErr) + return false, sErr + end + nFacInd = nFacAdj + dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + end + -- altrimenti se ho già cambiato faccia do errore per impossibilità di lavorazione + else + local sErr = 'Error : impossible to machine by side angle too big that cause collision' + EgtOutLog( sErr) + return false, sErr + end + end + -- eventuali tagli preliminari + do + local bOk, sErr = MakePreCuts( Proc) + if not bOk then return false, sErr end + end + -- imposto altezza aggiuntiva di elevazione + local dCollSic = CalcCollisionSafety( vtN) + -- abilitazione lavorazione da sotto + local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259) + local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.342) + -- settaggio voluto da Alessandro/Fabio (per fare angoli con fresa piccola) + local sMchFind = 'Pocket' + local dDiam = min( dH, dV) + local bTailOnSide = ( Proc.Box:getMin():getX() - _b3Solid:getMin():getX() < 0.1 and not Proc.Tail) + if ( Proc.Fct == 1) or (( Proc.Fct == 2 or Proc.Fct == 3) and bIsL) or ((( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 4 and not bTailOnSide)) and bSinglePart) then + sMchFind = 'OpenPocket' + if bIsU then + dDiam = GetUShapeWidth( Proc, nFacInd) or dDiam + elseif Proc.Fct == 4 then + -- per rifinire gli angoli premio utensile diam 25 o da BD + dDiam = min( dDiam, BD.MAXDIAM_POCK_CORNER or 30) + elseif Proc.Fct == 3 and bIsL then + -- per rifinire gli angoli premio utensile diam 25 o da BD + dDiam = min( 2 * dDiam, BD.MAXDIAM_POCK_CORNER or 30) + else + dDiam = 2 * dDiam + end + end + sMchFindBackUp = sMchFind + local nUseRoughTool = EgtIf( bSinglePart, 0, 1) + -- 04/08/2020 Se settato parametro uso truciolatore (parametro Q), non si devono prendere altre frese, si da errore (Fabio) + -- Questa opzione si scontra facilmente con altre interpretazioni dello stasso parametro Q (per tornare indietro bNewCheck = false) + local bNewCheck = true + -- se processo 20 e non sto usando il truciolatore + if bNewCheck and Proc.Prc == 20 and nUseRoughTool == 0 then + -- verifico se forzato uso truciolatore + if Q_USE_ROUGH_TOOL and Q_USE_ROUGH_TOOL ~= 0 then + sMchFind = 'OpenPocket' + nUseRoughTool = 1 + end + end + -- 03/12/2020 aggiunto controllo su feature 30 senza uso truciolatore + if bNewCheck and Proc.Prc == 30 and nUseRoughTool == 0 then + -- verifico se forzato uso truciolatore + if Q_SIDE_ROUGH_TOOL and Q_SIDE_ROUGH_TOOL ~= 0 then + sMchFind = 'OpenPocket' + nUseRoughTool = 1 + end + end + -- se processo 20 e non sto usando il truciolatore + if Proc.Prc == 20 and nUseRoughTool == 0 then + if Q_USE_ROUGH_TOOL and Q_USE_ROUGH_TOOL ~= 0 then + sMchFind = 'OpenPocket' + nUseRoughTool = 1 + end + end + -- se da sotto, imposto massima lunghezza secondo la direzione + local dMaxTotLen + if bMillDown and BD.GetBottomToolMaxTotLen then + dMaxTotLen = BD.GetBottomToolMaxTotLen( vtN) + end + -- ricerca lavorazione + local sPocketing + local _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind .. EgtIf( bMillDown, '_H2', '')) + if not sMyPocketing and bMillUp then + _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind) + bMillDown = false + end + --local sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind .. EgtIf( bMillDown, '_H2', ''), dDiam, dFacElev + dCollSic, dMaxTotLen) + --if not sMyPocketing then + -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind .. EgtIf( bMillDown, '_H2', ''), dDiam, nil, dMaxTotLen) + --end + --if not sMyPocketing and bMillUp then + -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic) + -- if not sMyPocketing then + -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind, dDiam) + -- end + -- bMillDown = false + --end + if sMyPocketing and + ( dMyTMaxDepth > dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * dFacElev + dCollSic and not bIsU) or ( bIsL and nUseRoughTool == 0)) then + sPocketing = sMyPocketing + end + if bMillDown then + sMchFind = sMchFind ..'_H2' + end + -- 2021.09.16 Richiesta di Fabio Squaratti per lavorazione "Lamello": + -- se ho attiva questo tipo di lavorazione (delle fresature) e una di queste feature: L016, L030, L032, L039 + -- verifico se sono compatibili con questa lavorazione forma a U e larga più dell'altezza tagliente e profondità compatibile con + local bSpecialMillOnSide + local dThickMillOnSide = 0 + local sMillingOnSide + local dToolDiamOnSide = 0 + local dMaxDepthOnSide = 0 + if ( Proc.Prc == 16 or Proc.Prc == 30 or Proc.Prc == 32 or Proc.Prc == 39) then + -- verifico se ho una gola con 3 facce ed eventualmente delle facce terminali: + -- faccio una copia della superfice ed elimino le facce che hanno dimensione X < 1 e le facce risultanti devono essere una U + local nTestId = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL + if nTestId then + local bNewIsU + local bExit + local nFaces = EgtSurfTmFacetCount( nTestId) + while not bExit and nFaces >= 3 do + local bDeleteFace + local nInt = 0 + while not bDeleteFace and nInt < nFaces do + nInt = nInt + 1 + local b3Facet = EgtSurfTmGetFacetBBoxGlob( nTestId, nInt-1, GDB_BB.STANDARD) + local vtN = EgtSurfTmFacetNormVersor( nTestId, nInt-1, GDB_ID.ROOT) + -- se dimensione faccia sulla X + if b3Facet:getDimX() < 1 or abs( vtN:getX()) > 0.1 then + EgtSurfTmRemoveFacet( nTestId, nInt-1) + bDeleteFace = true + end + end + nFaces = EgtSurfTmFacetCount( nTestId) + -- se non ho cancellato una faccia faccio il test per forma ad U + if not bDeleteFace then + -- ottengo il numero di facce rimanenti + bNewIsU = ( nFaces == 3 and not TestElleShape3( nTestId, true)) + bExit = true + end + end + -- verifico che la componente x della faccia 0 deve essere nulla + local vtN1 = EgtSurfTmFacetNormVersor( nTestId, 0, GDB_ID.ROOT) + if bNewIsU and abs( vtN1:getX()) > 0.01 then + bNewIsU = false + end + -- cancello la copia del percorso + EgtErase( nTestId) + + if bNewIsU and ( not BD.MIN_LEN_LAMELLO or + ( Proc.TotBox and Proc.TotBox:getDimX() > BD.MIN_LEN_LAMELLO) or + ( not Proc.TotBox and Proc.Box:getDimX() > BD.MIN_LEN_LAMELLO)) then + -- recupero la lavorazione + if BD.DOWN_HEAD and vtN:getZ() < BD.NZ_MINA then + sMillingOnSide = ML.FindMilling( 'SideMillAsBlade_H2') + else + sMillingOnSide = ML.FindMilling( 'SideMillAsBlade') + end + + if sMillingOnSide then + -- recupero i dati dell'utensile + local dToolLength = 0 + local sUserNote + if EgtMdbSetCurrMachining( sMillingOnSide) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength + dToolDiamOnSide = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamOnSide + dThickMillOnSide = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dThickMillOnSide + dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide + end + end + -- 2021.09.17 Su conferma di Fabio Squaratti, se la gola è più stretta dell'utensile o la profondità della gole è maggiore + -- del valore parametro SIDEDEPTH (preso dalle note utente dell'utensile) allora si prosegue come se non fosse abilitata + -- questo tipo di lavorazione SideMillAsBlade + if dDiam > dThickMillOnSide - 10 * GEO.EPS_SMALL and dFacElev < dMaxDepthOnSide + 10 * GEO.EPS_SMALL then + bSpecialMillOnSide = true + -- disabilito eventuale svuotatura + sPocketing = nil + end + end + end + end + end + -- se feature 16 e forzata lama e forma ad U, annulla la svuotatura + if Proc.Prc == 16 and _bForceUseBlade and Proc.Fct == 3 and bIsU then + sPocketing = nil + end + -- se lavorazione fresa come lama disabilito eventuale antischegggia + if bSpecialMillOnSide then Q_ANTISPLINT_TYPE = 0 end + -- se non trova una svuotatura adatta + if not sPocketing then + -- se forma a L provo con contornatura + if bIsL and not bSpecialMillOnSide then + -- se smusso non è esclusivo + if _nChamfer < 2 then + return MakeByMill( Proc, nFacInd, rfFac, dH, dV, dFacElev, dCollSic) + end + -- altrimenti, in base alla forma, provo con svuotature di fianco o con la sega a catena o lama + else + local stat, bOk, sWarn = MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, bSpecialMillOnSide, + nBottomFace, dMaxDepthOnSide, sMillingOnSide, + dToolDiamOnSide, dThickMillOnSide, bSinglePart, bIsU, bIsL, dDiam, + bMillDown, bMillUp, sMchFind, sMchFindBackUp) + if stat == 1 then + return bOk, sWarn + end + end + else + -- se devo inserire il chamfer + if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and _nChamfer > 0 then + -- ottengo le dimensioni dello pseudotunnel + local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc) + local nOk, sErr = MakeChamfer( Proc, true, vtOrtho, nSurfInt) + if nOk < 0 then return false, sErr end + end + end + -- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo + -- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa + -- 2021.04.27 esegue antischeggia di lama se forma U o L con feature passante in Y o Z + -- 2021.07.16 Per poter eseguire antischeggia di lama su feature che non sono passanti da faccia a faccia + -- ma che sono su un angolo (coinvolgono 2 facce contigue) è stato modificato il confronto in: + -- esegue antischeggia di lama se forma U o L con feature passante in Y o Z, oppure se feature a furma U e con 3 facce oppore a forma a L e con 2 facce + local bMadeASbyBld = false + local bPassThrou = ( Proc.Box:getDimY() > _b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > _b3Raw:getDimZ() - 1) + local bPassEdge = ((( bIsU and Proc.Fct == 3) or ( bIsL and Proc.Fct == 2)) and bSinglePart and Proc.Box:getDimX() < 0.9 * _b3Raw:getDimX()) + if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then + local bOk + local bSawDown = ( bMillDown and not bMillUp) + bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, vtN, nFacInd, sWarn, bSawDown) + if not bOk then return false, sWarn end + end + if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 2 then + local bOk, sWarn2 + bOk, sWarn2 = ManageAntiSplintByMill( Proc, nFacInd, bMillDown) + if not bOk then return false, sWarn2 end + end + -- se smusso non esclusivo + if _nChamfer < 2 then + -- eseguo la svuotatura della faccia principale, mi restituisce id utensile, il diametro utensile per il foro opzionale + local tvtNx = {} + tvtNx[2] = vtN + local bOk, sWarn2, sTuuidPk, dDiamTool + bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev + dCollSic) + if not bOk then return false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + -- se ho più di 3 facce e non di forma ad u oppure ho 3 facce e di forma ad u + -- e non sono stati inseriti antischeggia di lama + -- controllo se c'è una faccia non ortogonale alla principale e la lavoro con una contornatura o svuotatura + if ( ( Proc.Fct > 3 and not bIsU) or ( Proc.Fct == 3 and bIsU)) and not bMadeASbyBld then + -- Recupero le facce adiacenti alla principale (solo quelle esistenti) + local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) + if not vAdj or #vAdj == 0 then + local sErr = 'Error : main face without adjacencies' + EgtOutLog( sErr) + return false, sErr + end + -- Cerco una faccia adiacente alla principale con angolo > 90 + local nFacAdj + local tDimAndRef = {} + tvtNx = {} + tvtNx[1] = vtN + tDimAndRef[1] = {dH, dV, rfFac} + for i = 1, #vAdj do + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + if bAdj and dAng < 0 and 180 + dAng > 90.1 then + local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vAdj[i], GDB_ID.ROOT) + _, tvtNx[2] = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) + tDimAndRef[2] = {dH2, dV2, rfFac2} + local ptPs = ( ptP1 + ptP2) / 2 + local bOk, sWarn2 + bOk, sWarn2 = MachineByMill( Proc, tvtNx, nFacInd, vAdj[i], ptPs, tDimAndRef, + EgtIf( ( Proc.Fct == 3 and bIsU), 0, 2), nUseRoughTool, dAng, sPocketing, sTuuidPk, dFacElev) + if not bOk then return bOk, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + end + end + end + -- se abilitato dal parametro Q inserisco foro sullo spigolo + if Q_BORE_ON_CORNER == 1 then + local bOk, sWarn2 + bOk, sWarn2 = MakeDrillOnCorner( Proc, nFacInd, dDiamTool) + if not bOk then return false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + -- altrimenti se abilitato dal parametro Q inserisco percorso di pulitura + elseif Q_BORE_ON_CORNER == 2 then + local bOk, sWarn2 + bOk, sWarn2 = MakeSharpCleanCorner( Proc, nFacInd, dDiamTool) + if not bOk then return false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + -- altrimenti se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola + elseif Q_CONTOUR_SMALL_TOOL > 0 then + local bOk, sWarn2 + bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown) + if not bOk then return false, sWarn2 end + sWarn = FormatWarning(sWarn, sWarn2) + end + end + + return true, '' +end + +--------------------------------------------------------------------- +local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill) local sWarn - -- recupero l'ingombro del grezzo di appartenenza - local b3Raw = EgtGetRawPartBBox( nRawId) - -- recupero l'ingombro della trave - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not b3Solid then - local sErr = 'Error : part box not found' - EgtOutLog( sErr) - return false, sErr - end - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error : missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end local bClosedOrthoFaces - local nFacInd, dFacElev, nFacInd2, dFacElev2 local nBottomFace local sMchFindBackUp -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) + local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bClosedOrthoFaces = nFacInd2 @@ -4629,12 +5128,12 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if Proc.Prc == 16 and Proc.Fct == 5 and not bClosedOrthoFaces then -- dalla copia della superfice, ciclo eliminando una faccia per volta per verificare se trova fessura for i = 1, Proc.Fct do - local nNewProc = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + local nNewProc = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL -- elimino una faccia nBottomFace = i - 1 if EgtSurfTmRemoveFacet( nNewProc, nBottomFace) then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( nNewProc, nPartId) + nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( nNewProc, _nPartId) if not nFacInd or nFacInd < 0 then if nFacInd == -1 then bClosedOrthoFaces = nFacInd2 @@ -4662,13 +5161,10 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa bClosedOrthoFaces = false -- non setto come tunnel end end - -- verifico se sono presenti i parametri Q per la profondità smusso e - -- per eseguire in esclusiva solo lo smusso - local nChamfer, dDepthCham, sErrCham, bForceUseBlade = EvaluateQParam( Proc) -- 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, sErrCham + if _nChamfer < 0 then + return false, _sErrCham end -- se è un tunnel provo a vedere se è possibile lavorarlo con la svuotatura o con la sega catena if bClosedOrthoFaces then @@ -4676,85 +5172,22 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- lavoro fessura con svuotature (singola o doppia contrapposta) local sMyMchFind = 'Pocket' local nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace = - MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, false, b3Solid, bClosedOrthoFaces) + MakeByPockets( Proc, sMyMchFind, false, bClosedOrthoFaces) if nOk < 0 then return false, sErr elseif nOk > 0 then bTryWithBlades = false end -- Se la svuotatura precedente non è stata fatta e chamfer non è mutuamente esclusivo provo con la sega-catena - if bTryWithBlades and nChamfer < 2 then + if bTryWithBlades and _nChamfer < 2 then -- verifico se posso farlo con la sega-catena - local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifyChainSaw( Proc, dDimMin, dDimMax) - 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) - else - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK) - end - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nLundIdFace, GDB_ID.ROOT) - -- imposto angolo 3° asse rot - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 1)) - EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, vtOrtho)) - -- 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 : elevation bigger than max tool depth' - EgtOutLog( sWarn) - end - -- eseguo - if not EgtApplyMachining( true, false) then - if EgtGetOutstrokeInfo() then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 2)) - EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, vtOrtho)) - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - end - if EgtIsMachiningEmpty() then - _, sWarn = EgtGetMachMgrWarning( 0) - EgtSetOperationMode( nMchFId, false) - return false, sWarn - end - end + local bOk, sErr = MakeByChainsaw(Proc, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace) + if not bOk then + return false, sErr end end -- altrimenti non è una fessura 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 @@ -4766,618 +5199,52 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if bPrevBhSideMill == nil then bPrevBhSideMill = bMakeBySideMill end --- if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then + --if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then if bMakeBySideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo - if nChamfer < 2 then - local bOk, sErr = MakeBySideMill() + if _nChamfer < 2 then + local bOk, sErr = MakeBySideMill(Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dToolDiam, bHeadDir) return bOk, sErr end -- altrimenti lavoro con svuotatura - else - local bSpecial3faces = false - - -- 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) + else + local bSpecial3faces = false local bBoxF = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfFac) - + if dH * dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then bSpecial3faces = true - --- --- - --ShowFacesNumber( Proc.Id) - end - + end + -- se riconosciuta gestione 3 facce -- e limitata per ora alla feature 20 if bSpecial3faces and Proc.Prc == 20 and nFacInd2 then -- se smusso non è esclusivo - if nChamfer < 2 then - local bOk, sErr = MakeSpecialThreeFaces( Proc, nPhase, bIsL, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nChamfer) + if _nChamfer < 2 then + local bOk, sErr = MakeSpecialThreeFaces( Proc, bIsL) return bOk, sErr - end + end -- altrimenti lavorazione di svuotatura o contornatura - else - local bUseOtherFace - -- se orientata verso il basso e non c'è testa da sotto, verifico l'alternativa - if vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD and nFacInd2 then - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - bUseOtherFace = true - end - -- verifico non sia orientata verso il basso o ci sia una testa dal basso - local bFaceDown = ( vtN:getZ() < BD.NZ_MINA) - if bFaceDown and not BD.DOWN_HEAD then - local sErr = 'Error : LapJoint from bottom impossible' - EgtOutLog( sErr) - return false, sErr - end - --- rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - -- se forma a L e la componente in X è maggiore di 60° e non in testa allora verifico se posso utilizzare la faccia secondaria - if bIsL and abs( vtN:getX()) > 0.866 and - ( Proc.Box:getMax():getX() < b3Solid:getMax():getX() - 10 or vtN:getX() < 0) and - ( not Proc.Tail or vtN:getX() > 0) then - -- se non ho scambiato la faccia - if not bUseOtherFace then - if nFacInd2 then - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - -- altrimenti cerco la faccia secondaria per adiacenza alla principale - else - -- Cerco una faccia adiacente alla principale sul lato lungo - local nFacAdj, sErr = GetFaceAdj( Proc, nFacInd, dH, dV) - if nFacAdj < 0 then - EgtOutLog( sErr) - return false, sErr - end - nFacInd = nFacAdj - dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - end - -- altrimenti se ho già cambiato faccia do errore per impossibilità di lavorazione - else - local sErr = 'Error : impossible to machine by side angle too big that cause collision' - EgtOutLog( sErr) - return false, sErr - end - end - -- eventuali tagli preliminari - do - local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer) - if not bOk then return false, sErr end - end - -- imposto altezza aggiuntiva di elevazione - local dCollSic = CalcCollisionSafety( vtN) - -- abilitazione lavorazione da sotto - local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259) - local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.342) - -- settaggio voluto da Alessandro/Fabio (per fare angoli con fresa piccola) - local sMchFind = 'Pocket' - local dDiam = min( dH, dV) - local bTailOnSide = ( Proc.Box:getMin():getX() - b3Solid:getMin():getX() < 0.1 and not Proc.Tail) - if ( Proc.Fct == 1) or (( Proc.Fct == 2 or Proc.Fct == 3) and bIsL) or ((( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 4 and not bTailOnSide)) and bSinglePart) then - sMchFind = 'OpenPocket' - if bIsU then - dDiam = GetUShapeWidth( Proc, nFacInd) or dDiam - elseif Proc.Fct == 4 then - -- per rifinire gli angoli premio utensile diam 25 o da BD - dDiam = min( dDiam, BD.MAXDIAM_POCK_CORNER or 30) - elseif Proc.Fct == 3 and bIsL then - -- per rifinire gli angoli premio utensile diam 25 o da BD - dDiam = min( 2 * dDiam, BD.MAXDIAM_POCK_CORNER or 30) - else - dDiam = 2 * dDiam - end - end - sMchFindBackUp = sMchFind - local nUseRoughTool = EgtIf( bSinglePart, 0, 1) - -- 04/08/2020 Se settato parametro uso truciolatore (parametro Q), non si devono prendere altre frese, si da errore (Fabio) - -- Questa opzione si scontra facilmente con altre interpretazioni dello stasso parametro Q (per tornare indietro bNewCheck = false) - local bNewCheck = true - -- se processo 20 e non sto usando il truciolatore - if bNewCheck and Proc.Prc == 20 and nUseRoughTool == 0 then - -- verifico se forzato uso truciolatore - if Q_USE_ROUGH_TOOL and Q_USE_ROUGH_TOOL ~= 0 then - sMchFind = 'OpenPocket' - nUseRoughTool = 1 - end - end - -- 03/12/2020 aggiunto controllo su feature 30 senza uso truciolatore - if bNewCheck and Proc.Prc == 30 and nUseRoughTool == 0 then - -- verifico se forzato uso truciolatore - if Q_SIDE_ROUGH_TOOL and Q_SIDE_ROUGH_TOOL ~= 0 then - sMchFind = 'OpenPocket' - nUseRoughTool = 1 - end - end - -- se processo 20 e non sto usando il truciolatore - if Proc.Prc == 20 and nUseRoughTool == 0 then - if Q_USE_ROUGH_TOOL and Q_USE_ROUGH_TOOL ~= 0 then - sMchFind = 'OpenPocket' - nUseRoughTool = 1 - end - end - -- se da sotto, imposto massima lunghezza secondo la direzione - local dMaxTotLen - if bMillDown and BD.GetBottomToolMaxTotLen then - dMaxTotLen = BD.GetBottomToolMaxTotLen( vtN) - end - -- ricerca lavorazione - local sPocketing - local _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind .. EgtIf( bMillDown, '_H2', '')) - if not sMyPocketing and bMillUp then - _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind) - bMillDown = false - end - --local sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind .. EgtIf( bMillDown, '_H2', ''), dDiam, dFacElev + dCollSic, dMaxTotLen) - --if not sMyPocketing then - -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind .. EgtIf( bMillDown, '_H2', ''), dDiam, nil, dMaxTotLen) - --end - --if not sMyPocketing and bMillUp then - -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic) - -- if not sMyPocketing then - -- sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind, dDiam) - -- end - -- bMillDown = false - --end - if sMyPocketing and - ( dMyTMaxDepth > dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * dFacElev + dCollSic and not bIsU) or ( bIsL and nUseRoughTool == 0)) then - sPocketing = sMyPocketing - end - if bMillDown then - sMchFind = sMchFind ..'_H2' - end - -- 2021.09.16 Richiesta di Fabio Squaratti per lavorazione "Lamello": - -- se ho attiva questo tipo di lavorazione (delle fresature) e una di queste feature: L016, L030, L032, L039 - -- verifico se sono compatibili con questa lavorazione forma a U e larga più dell'altezza tagliente e profondità compatibile con - local bSpecialMillOnSide - local dThickMillOnSide = 0 - local sMillingOnSide - local dToolDiamOnSide = 0 - local dMaxDepthOnSide = 0 - if ( Proc.Prc == 16 or Proc.Prc == 30 or Proc.Prc == 32 or Proc.Prc == 39) then - -- verifico se ho una gola con 3 facce ed eventualmente delle facce terminali: - -- faccio una copia della superfice ed elimino le facce che hanno dimensione X < 1 e le facce risultanti devono essere una U - local nTestId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL - if nTestId then - local bNewIsU - local bExit - local nFaces = EgtSurfTmFacetCount( nTestId) - while not bExit and nFaces >= 3 do - local bDeleteFace - local nInt = 0 - while not bDeleteFace and nInt < nFaces do - nInt = nInt + 1 - local b3Facet = EgtSurfTmGetFacetBBoxGlob( nTestId, nInt-1, GDB_BB.STANDARD) - local vtN = EgtSurfTmFacetNormVersor( nTestId, nInt-1, GDB_ID.ROOT) - -- se dimensione faccia sulla X - if b3Facet:getDimX() < 1 or abs( vtN:getX()) > 0.1 then - EgtSurfTmRemoveFacet( nTestId, nInt-1) - bDeleteFace = true - end - end - nFaces = EgtSurfTmFacetCount( nTestId) - -- se non ho cancellato una faccia faccio il test per forma ad U - if not bDeleteFace then - -- ottengo il numero di facce rimanenti - bNewIsU = ( nFaces == 3 and not TestElleShape3( nTestId, true)) - bExit = true - end - end - -- verifico che la componente x della faccia o deve essere nulla - local vtN1 = EgtSurfTmFacetNormVersor( nTestId, 0, GDB_ID.ROOT) - if bNewIsU and abs( vtN1:getX()) > 0.01 then - bNewIsU = false - end - -- cancello la copia del percorso - EgtErase( nTestId) - - if bNewIsU and ( not BD.MIN_LEN_LAMELLO or - ( Proc.TotBox and Proc.TotBox:getDimX() > BD.MIN_LEN_LAMELLO) or - ( not Proc.TotBox and Proc.Box:getDimX() > BD.MIN_LEN_LAMELLO)) then - -- recupero la lavorazione - if BD.DOWN_HEAD and vtN:getZ() < BD.NZ_MINA then - sMillingOnSide = ML.FindMilling( 'SideMillAsBlade_H2') - else - sMillingOnSide = ML.FindMilling( 'SideMillAsBlade') - end - - if sMillingOnSide then - -- recupero i dati dell'utensile - local dToolLength = 0 - local sUserNote - if EgtMdbSetCurrMachining( sMillingOnSide) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength - dToolDiamOnSide = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamOnSide - dThickMillOnSide = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dThickMillOnSide - dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide - end - end - -- 2021.09.17 Su conferma di Fabio Squaratti, se la gola è più streta dell'utensile o la profondità della gole è maggiore - -- del valore parametro SIDEDEPTH (preso dalle note utente dell'utensile) allora si prosegue come se non fosse abilitata - -- questo tipo di lavorazione SideMillAsBlade - if dDiam > dThickMillOnSide - 10 * GEO.EPS_SMALL and dFacElev < dMaxDepthOnSide + 10 * GEO.EPS_SMALL then - bSpecialMillOnSide = true - -- disabilito eventulae svuotatura - sPocketing = nil - end - end - end - end - end - -- se feature 16 e forzata lama e forma ad U, annulla la svuotatura - if Proc.Prc == 16 and bForceUseBlade and Proc.Fct == 3 and bIsU then - sPocketing = nil - end - -- leggo parametro Q - local nQAntisplintResult = Q_ANTISPLINT_TYPE - -- se lavorazione fresa come lama disabilito eventuale antischegggia - if bSpecialMillOnSide then nQAntisplintResult = 0 end - -- se non trova una svuotatura adatta - if not sPocketing then - -- se forma a L provo con contornatura - if bIsL and not bSpecialMillOnSide then - -- se smusso non è esclusivo - if nChamfer < 2 then - return MakeByMill( Proc, nFacInd, rfFac, dH, dV, dFacElev, dCollSic) - end - -- altrimenti, in base alla forma, provo con svuotature di fianco o con la sega a catena o lama - else - local bTryWithBlades = true - local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nSurfInt - if bSpecialMillOnSide then - -- eseguo - bOk, sWarn = MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, - rfFac, dH, dV, dFacElev, bSpecialMillOnSide, - nBottomFace, nAddGrpId, b3Solid, dMaxDepthOnSide, sMillingOnSide, - dToolDiamOnSide, dThickMillOnSide) - if bOk then - return true, sWarn - end - end - -- se feature 16 o 17 e se forzata lama provo prima con questa e poi con la fresa - if ( Proc.Prc == 16 or Proc.Prc == 17) and bForceUseBlade then - -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame - if bTryWithBlades and nChamfer < 2 then - -- anche su macchine con testa da sotto, la sega a catena è solo da sopra - if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - bUseOtherFace = true - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - end - -- eseguo - bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, - rfFac, dH, dV, dFacElev, bForceUseBlade, - dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, - bOrthoFaces, nBottomFace, nChamfer, nAddGrpId, b3Solid, - dDepthCham, nSurfInt, true) - if not bOk then - -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e - -- se non è possibile allora provo in seguito con lama o segacatena - -- 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, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, true, b3Solid, 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 - sMchFind = sMchFindBackUp - end - sPocketing = ML.FindPocketing( sMchFind, dDiam) - if not sPocketing then - local sErr = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr) - return false, sErr - end - elseif nOk < 0 then - return false, sErr - elseif nOk == 0 then - if sStat == 'MNF' then - sPocketing = ML.FindPocketing( sMchFind, dDiam) - if not sPocketing then - local sErr = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr) - return false, sErr - end - else - return bOk, sWarn - end - else - bOk = true - return bOk, sErr - end - else - sPocketing = ML.FindPocketing( sMchFind, dDiam) - if not sPocketing then - local sErr = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr) - return false, sErr - end - end - else - return bOk, sWarn - end - else - -- se devo inserire il chamfer - if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then - -- ottengo le dimensioni dello pseudotunnel - local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) - local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) - if nOk < 0 then return false, sErr end - end - bOk = true - return bOk, sWarn - end - else - -- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo - -- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa - -- 2021.04.27 esegue antischeggia di lama se forma U o L con feature passante in Y o Z - -- 2021.07.16 Per poter eseguire antischeggia di lama su feature che non sono passanti da faccia a faccia - -- ma che sono su un angolo (coinvolgono 2 facce contigue) è stato modificato il confronto in: - -- esegue antischeggia di lama se forma U o L con feature passante in Y o Z, oppure se feature a furma U e con 3 facce oppore a forma a L e con 2 facce - local bMadeASbyBld = false - local bPassThrou = ( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) - local bPassEdge = ((( bIsU and Proc.Fct == 3) or ( bIsL and Proc.Fct == 2)) and bSinglePart and Proc.Box:getDimX() < 0.9 * b3Raw:getDimX()) - if nChamfer < 2 and nQAntisplintResult == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then - local bOk - local bSawDown = ( bMillDown and not bMillUp) - bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bSawDown, true) - if not bOk then return false, sWarn end - end - -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e - -- se non è possibile allora provo in seguito con lama o segacatena - -- 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, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, true, b3Solid, nil, bMillDown) - if nOk == -2 then - if not sMchFind then - sMchFind = sMchFindBackUp - end - sPocketing = ML.FindPocketing( sMchFind, dDiam) - if not sPocketing then - local sErr2 = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr2) - return false, sErr2 - end - bTryWithBlades = false - sWarn = sErr - elseif nOk < 0 then - return false, sErr - elseif nOk > 0 then - 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 then - local bOk, sWarn2 = ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, bMillDown, dDiamTool, bDoubleSide, - vtOrtho, nPathInt, nSurfInt, b3Solid, dDepth, - bOneShot, nFirstMachId) - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola - local nContourSmallTool = Q_CONTOUR_SMALL_TOOL - if nContourSmallTool > 0 then - local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiamTool, nContourSmallTool, bMillDown, - bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, - dDepth, bOneShotm) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - end - bOk = true - end - -- 03/09/2020 da conferma di Fabio Squaratti: Per ora solo sulla feature 016: - -- se ha fallito la fresatura (qua sopra) allora di defalut ( anche se il flag Q della lama è disattivato) prima provo la lama - if Proc.Prc == 16 then - bForceUseBlade = true - end - -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame - if bTryWithBlades and nChamfer < 2 then - -- anche su macchine con testa da sotto, la sega a catena è solo da sopra - if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - bUseOtherFace = true - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - end - -- eseguo - bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, - rfFac, dH, dV, dFacElev, bForceUseBlade, - dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, - bOrthoFaces, nBottomFace, nChamfer, nAddGrpId, b3Solid, - dDepthCham, nSurfInt) - if not bOk and sStat == 'MNF' then - _, sPocketing = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, nil, sMchFind) - if sPocketing then - sWarn = '' - else - local sErr2 = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr2) - return false, sErr2 - end - else - -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola - local nContourSmallTool = Q_CONTOUR_SMALL_TOOL - if nContourSmallTool > 0 then - local bOk, sWarn2 - bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, 100, nContourSmallTool, bMillDown) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - return bOk, sWarn - end - -- altrimenti verifico se ho già svuotato dal fianco, se si esco - else - -- se non ho annullato la/le svuotatura/e dal fianco - if nOk ~= -2 then - return bOk, sWarn - end - end - end - end - else - -- se devo inserire il chamfer - if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then - -- ottengo le dimensioni dello pseudotunnel - local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) - local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) - if nOk < 0 then return false, sErr end - end - end - -- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo - -- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa - -- 2021.04.27 esegue antischeggia di lama se forma U o L con feature passante in Y o Z - -- 2021.07.16 Per poter eseguire antischeggia di lama su feature che non sono passanti da faccia a faccia - -- ma che sono su un angolo (coinvolgono 2 facce contigue) è stato modificato il confronto in: - -- esegue antischeggia di lama se forma U o L con feature passante in Y o Z, oppure se feature a furma U e con 3 facce oppore a forma a L e con 2 facce - local bMadeASbyBld = false - local bPassThrou = ( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) - local bPassEdge = ((( bIsU and Proc.Fct == 3) or ( bIsL and Proc.Fct == 2)) and bSinglePart and Proc.Box:getDimX() < 0.9 * b3Raw:getDimX()) - if nChamfer < 2 and nQAntisplintResult == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then - local bOk - local bSawDown = ( bMillDown and not bMillUp) - bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bSawDown) - if not bOk then return false, sWarn end - end - if nChamfer < 2 and nQAntisplintResult == 2 then - local bOk, sWarn2 - bOk, sWarn2 = ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, bMillDown) - if not bOk then return false, sWarn2 end - end - -- se smusso non esclusivo - if nChamfer < 2 then - -- eseguo la svuotatura della faccia principale, mi restituisce id utensile, il diametro utensile per il foro opzionale - local tvtNx = {} - tvtNx[2] = vtN - local bOk, sWarn2, sTuuidPk, dDiamTool - bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev + dCollSic) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - -- se ho più di 3 facce e non di forma ad u oppure ho 3 facce e di forma ad u - -- e non sono stati inseriti antischeggia di lama - -- controllo se c'è una faccia non ortogonale alla principale e la lavoro con una contornatura o svuotatura - if ( ( Proc.Fct > 3 and not bIsU) or ( Proc.Fct == 3 and bIsU)) and not bMadeASbyBld then - -- Recupero le facce adiacenti alla principale - local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] - if not vAdj or #vAdj == 0 then - local sErr = 'Error : main face without adjacencies' - EgtOutLog( sErr) - return false, sErr - end - -- Cerco una faccia adiacente alla principale con angolo > 90 - local nFacAdj - local tDimAndRef = {} - tvtNx = {} - tvtNx[1] = vtN - tDimAndRef[1] = {dH, dV, rfFac} - for i = 1, #vAdj do - if vAdj[i] >= 0 then - local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) - if bAdj and dAng < 0 and 180 + dAng > 90.1 then - local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vAdj[i], GDB_ID.ROOT) - _, tvtNx[2] = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) - tDimAndRef[2] = {dH2, dV2, rfFac2} - local ptPs = ( ptP1 + ptP2) / 2 - local bOk, sWarn2 - bOk, sWarn2 = MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtNx, nFacInd, vAdj[i], ptPs, tDimAndRef, - b3Raw, EgtIf( ( Proc.Fct == 3 and bIsU), 0, 2), nUseRoughTool, dAng, sPocketing, sTuuidPk, dFacElev) - if not bOk then return bOk, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - end - end - end - local nBoreOnCorner = Q_BORE_ON_CORNER - local nContourSmallTool = Q_CONTOUR_SMALL_TOOL - -- se abilitato dal parametro Q inserisco foro sullo spigolo - if nBoreOnCorner == 1 then - local bOk, sWarn2 - bOk, sWarn2 = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - -- altrimenti se abilitato dal parametro Q inserisco percorso di pulitura - elseif nBoreOnCorner == 2 then - local bOk, sWarn2 - bOk, sWarn2 = MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - -- altrimenti se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola - elseif nContourSmallTool > 0 then - local bOk, sWarn2 - bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiamTool, nContourSmallTool, bMillDown) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - end + else + local bOk, sErr = MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev) + return bOk, sErr end end end return true, sWarn, bPrevBhSideMill end - + --------------------------------------------------------------------- -local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error : missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end - -- recupero l'ingombro del grezzo di appartenenza - local b3Raw = EgtGetRawPartBBox( nRawId) - -- la divido in parti lungo X +local function MakeLongMoreFaces( Proc) + + -- divido in parti lungo la X local vAddId = {} local nPart = max( ceil( Proc.Box:getDimX() / BD.LONGCUT_MAXLEN), 2) local dPartLen = Proc.Box:getDimX() / nPart local Xmin = Proc.Box:getMin():getX() for i = 1, nPart do -- eseguo divisione - local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + local AddId = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL EgtSetName( AddId, 'AddPart_' .. tostring( Proc.Id) .. '_' .. tostring( i)) if i > 1 then local ptOn = Point3d( Xmin + ( i - 1) * dPartLen, 0, 0) @@ -5399,7 +5266,7 @@ local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) local AddProc = { Id = vAddId[i], Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Box, TotBox = Proc.Box, Fct = nFct, Flg = Proc.Flg} -- lasciare il false nel sesto parametro (perchè internamente viene verificato se diverso da nil) local bOk, sMyWarn - bOk, sMyWarn, bPrevBhSideMill = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, dOvmHead, false, bPrevBhSideMill) + bOk, sMyWarn, bPrevBhSideMill = MakeMoreFaces( AddProc, false, bPrevBhSideMill) if not sWarn then sWarn = sMyWarn end if not bOk then return bOk, sWarn end end @@ -5410,21 +5277,15 @@ end -- Applicazione della lavorazione --------------------------------------------------------------------- function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) - -- setto a nil la variabile smussi - bMadeChamfer = nil + -- inizializzo variabili globali al modulo + local bOk, sErr = InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) + + if not bOk then + return bOk, sErr + end + -- limiti di fresatura semplice local MAX_MILL_LIN = 80 - -- recupero l'ingombro del grezzo di appartenenza - local b3Raw = EgtGetRawPartBBox( nRawId) - -- recupero l'ingombro della trave - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not b3Solid then - local sErr = 'Error : part box not found' - EgtOutLog( sErr) - return false, sErr - end - -- in base al tipo di feature leggo i valori dei parametri Q - AssignQValues( Proc) -- se non forzate frese, uso la lama local bUseBlade = Q_USE_ROUGH_TOOL ~= 1 and Q_USE_MILL ~= 1 local nForceUseBladeOnNotContinueFace @@ -5452,13 +5313,13 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- se lunghezza richiede spezzatura if ( Proc.Box:getDimX() > BD.LONGCUT_MAXLEN) or - ( Proc.Box:getDimX() > 0.8 * b3Solid:getDimX() and Proc.Box:getDimX() > BD.LONGCUT_ENDLEN) then + ( Proc.Box:getDimX() > 0.8 * _b3Solid:getDimX() and Proc.Box:getDimX() > BD.LONGCUT_ENDLEN) then -- una faccia if Proc.Fct == 1 then if bUseBlade and nForceUseBladeOnNotContinueFace and nForceUseBladeOnNotContinueFace > 0 then - return LongCut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) else - return LongCut.Make( Proc, nPhase, nRawId, nPartId) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId) end -- due facce elseif Proc.Fct == 2 then @@ -5468,35 +5329,35 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if abs( b3Fac1:getDimX() - b3Fac2:getDimX()) < 50 then -- leggo i parametri Q per utilizzare la fresa di fianco e/o lama local nUseSideTool = Q_SIDE_ROUGH_TOOL - local bUseBlade = Q_ANTISPLINT_TYPE == 1 -- EgtGetInfo( Proc.Id, Q_ANTISPLINT_TYPE, 'i') == 1 ?? - return Long2Cut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nUseSideTool) + local bUseBlade = Q_ANTISPLINT_TYPE == 1 + return Long2Cut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nUseSideTool) elseif b3Fac1:getDimX() < 1 then -- la faccia 0 deve essere quella lunga EgtSurfTmSwapFacets( Proc.Id, 0, 1) if bUseBlade then if nForceUseBladeOnNotContinueFace and nForceUseBladeOnNotContinueFace > 0 then - return LongCut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) else - return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') + return Fbs.MakeTwo( Proc, _nPhase, _nRawId, _nPartId, _dOvmHead, 'HeadSide') end else - return LongCut.Make( Proc, nPhase, nRawId, nPartId) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId) end elseif b3Fac2:getDimX() < 1 then if bUseBlade then if nForceUseBladeOnNotContinueFace and nForceUseBladeOnNotContinueFace > 0 then - return LongCut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) else - return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') + return Fbs.MakeTwo( Proc, _nPhase, _nRawId, _nPartId, _dOvmHead, 'HeadSide') end else - return LongCut.Make( Proc, nPhase, nRawId, nPartId) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId) end else if bUseBlade then - return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') + return Fbs.MakeTwo( Proc, _nPhase, _nRawId, _nPartId, _dOvmHead, 'HeadSide') else - return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) + return MakeLongMoreFaces( Proc) end end -- tre facce @@ -5520,13 +5381,13 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end if bApplyBladeOnLongNotContinueFace and bUseBlade and nForceUseBladeOnNotContinueFace and nForceUseBladeOnNotContinueFace > 0 then - return LongCut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) + return LongCut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nForceUseBladeOnNotContinueFace) else - return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) + return MakeLongMoreFaces( Proc) end -- più facce else - return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) + return MakeLongMoreFaces( Proc) end -- altrimenti lavorazione unica else @@ -5534,17 +5395,16 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if Proc.Fct == 1 then -- se piccola, con fresa if not bUseBlade and ( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) then - return MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) + return MakeOneFaceByMill( Proc) -- altrimenti, con lama else - return Cut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + return Cut.Make( Proc, _nPhase, _nRawId, _nPartId, _dOvmHead) end -- due facce elseif Proc.Fct == 2 then -- se praticamente è lunga come la trave - if Proc.Box:getDimX() > 0.8 * b3Solid:getDimX() then - local nUseSideTool = Q_SIDE_ROUGH_TOOL - return Long2Cut.Make( Proc, nPhase, nRawId, nPartId, bUseBlade, nUseSideTool) + if Proc.Box:getDimX() > 0.8 * _b3Solid:getDimX() then + return Long2Cut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, Q_SIDE_ROUGH_TOOL) -- altrimenti else -- verifico se da lavorare con testa da sotto @@ -5563,36 +5423,26 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if ( not bUseBlade or bDownHead) and bAdj and abs( dAng + 90) < 1 then -- se piccole if Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN) then - return MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) + return MakeTwoFacesByMill( Proc, bDownHead) else - return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) + return MakeMoreFaces( Proc, true) end -- altrimenti, con lama else - -- verifico se devo fare prima gli smussi - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error : missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end -- 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) - -- verifico se sono presenti i parametri Q per la profondità smusso e - -- per eseguire in esclusiva solo lo smusso - local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc) - if Proc.Fct == 2 and bIsL and nChamfer > 0 then - local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) - local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + + if Proc.Fct == 2 and bIsL and _nChamfer > 0 then + local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc) + local nOk, sErr = MakeChamfer( Proc, true, vtOrtho, _b3Solid, nSurfInt) if nOk < 0 then return false, sErr end end - return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide' .. EgtIf( bDownHead, '_H2', ''), true, bDownHead) + return Fbs.MakeTwo( Proc, _nPhase, _nRawId, _nPartId, _dOvmHead, 'HeadSide' .. EgtIf( bDownHead, '_H2', ''), true, bDownHead) end end -- tre o più facce else - return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) + return MakeMoreFaces( Proc, true) end end end