-- ProcessText.lua by Egaltech s.r.l. 2022/12/05 -- Gestione calcolo testi per Travi -- 2021/05/03 Aggiunta gestione testa da sotto. -- 2022/12/05 Aggiunta gestione tipo di lavorazione Text_AT. -- Tabella per definizione modulo local ProcessText = {} -- Include require( 'EgtBase') EgtOutLog( ' ProcessText started', 1) -- Dati local BD = require( 'BeamData') local ML = require( 'MachiningLib') --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessText.Identify( Proc) return ( Proc.Grp == 4 and Proc.Prc == 61) end --------------------------------------------------------------------- -- Classificazione della feature function ProcessText.Classify( Proc) -- recupero i dati del testo local vtN = EgtTextNormVersor( Proc.Id, GDB_ID.ROOT) -- verifico sia un testo if not vtN then return false end -- verifico se il testo è lavorabile solo da sotto local bDown = (( vtN:getZ() < -0.1)) -- se da sotto e presente rinvio angolare verifico se c'è opportuna lavorazione if bDown and BD.ANG_TRASM then if ML.FindMilling( 'Text_AT') then bDown = false end end return true, bDown end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessText.Make( Proc, nPhase, nRawId, nPartId) -- recupero i dati del testo local vtN = EgtTextNormVersor( Proc.Id, GDB_ID.ROOT) -- verifico sia un testo if not vtN then local sErr = 'Error : Text with geometry type not accepted' EgtOutLog( sErr) return false, sErr end -- verifico che il testo non sia orientato verso il basso (-5 deg) if vtN:getZ() < - 0.1 and not BD.DOWN_HEAD and not BD.ANG_TRASM and not BD.TURN then local sErr = 'Error : Text from bottom impossible' EgtOutLog( sErr) return false, sErr end -- abilitazione lavorazione da sotto local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259) local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.174) local bMillAngTrasm = ( BD.ANG_TRASM and vtN:getZ() < -0.1) -- recupero la lavorazione local sMillType = EgtIf( not bMillAngTrasm, 'Text', 'Text_AT') local sMilling = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown) if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) return false, sErr end -- inserisco la lavorazione di fresatura local sName = 'Text_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) if not nMchFId then local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, -1}}) -- imposto posizione braccio porta testa local nSCC = MCH_SCC.NONE if bMillAngTrasm then nSCC = MCH_SCC.ADIR_NEAR else nSCC = EgtIf( vtN:getY() <= 0, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end return true end --------------------------------------------------------------------- return ProcessText