-- ProcessPocket.lua by Egaltech s.r.l. 2018/10/21 -- Gestione calcolo tasche per Travi -- Tabella per definizione modulo local ProcessPocket = {} -- Include require( 'EgtBase') local BL = require( 'BeamLib') EgtOutLog( ' ProcessPocket started', 1) -- Dati local BD = require( 'BeamData') local Pocketings = require( 'PocketingData') --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessPocket.Identify( Proc) return ( ( Proc.Grp == 4 and Proc.Prc == 39) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32)) end --------------------------------------------------------------------- -- Classificazione della feature function ProcessPocket.Classify( Proc) -- recupero la faccia con il maggior numero di adiacenze e più grande local nFacInd = BL.GetFaceWithMostAdj( Proc.Id) if not nFacInd then return false end -- recupero i dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) -- verifico se la mortasa è lavorabile solo da sotto local bDown = ( vtN:getZ() < - 0.1) return true, bDown end --------------------------------------------------------------------- local function FindPocketing( sType) for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.Type == sType then return i, Pocketing.Name end end return 0 end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessPocket.Make( Proc, nPhase, nRawId, nPartId) -- recupero la faccia con il maggior numero di adiacenze e più grande local nFacInd = BL.GetFaceWithMostAdj( Proc.Id) if not nFacInd then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' bottom face not found' EgtOutLog( sErr) return false, sErr end -- ne recupero i dati local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3) -- verifico che la mortasa non sia orientata verso il basso (-5 deg) if vtN:getZ() < - 0.1 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Pocket from bottom impossible' EgtOutLog( sErr) return false, sErr end -- recupero la lavorazione local nPocket, sPocketing = FindPocketing( 'Mortise') if not sPocketing then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' EgtOutLog( sErr) return false, sErr end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sPocketing) if not nMchFId then local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}}) -- imposto posizione braccio porta testa if vtN:getY() < - GEO.EPS_SMALL then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) else EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) end -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end return true end --------------------------------------------------------------------- return ProcessPocket