-- ProcessSplit.lua by Egaltech s.r.l. 2025/06/20 -- Gestione tastatura -- Tabella per definizione modulo local ProcessProbing = {} -- Include require( 'EgtBase') local BL = require( 'BeamLib') -- Dati local ML = require( 'MachiningLib') --------------------------------------------------------------------- local function GetProbingMachining( Machinings, sHead) local sProbeMachining, sHeadTool -- TODO questa associazione "testa utensile"-"testa tastatore" dovrebbe essere spostata nella macchina. -- Non è detto che se testa utensile inizia con "H2" allora bisogna prendere lavorazione con "_H2" -- se la testa utilizzata dalla lavorazione inizia con H2, dovrebbe essere la seconda testa if EgtStartsWith( sHead, 'H2') then sHeadTool = '_H2' else sHeadTool = '_H1' end for i = 1, #Machinings do if EgtEndsWith( Machinings[i].Name, sHeadTool) then sProbeMachining = Machinings[i] return sProbeMachining end end sProbeMachining = Machinings[1] return sProbeMachining end --------------------------------------------------------------------- local function MoveProbePointToRawFaces( ptProbe, vtProbe, nPartId) local b3BoxPart = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) -- si porta linea di tastatura su grezzo if AreSameVectorApprox( vtProbe, Z_AX()) then ptProbe[3] = b3BoxPart:getMax():getZ() elseif AreSameVectorApprox( vtProbe, -Z_AX()) then ptProbe[3] = b3BoxPart:getMin():getZ() elseif AreSameVectorApprox( vtProbe, Y_AX()) then ptProbe[2] = b3BoxPart:getMax():getY() elseif AreSameVectorApprox( vtProbe, -Y_AX()) then ptProbe[2] = b3BoxPart:getMin():getY() end return ptProbe end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProbing.Make( Proc, nPartId, Info) local bOk, sErr -- per eseguire tastatura servono tutti i dati, altriemnti impossibile if Info.vtProbe and Info.ptProbe and Info.sType then Info.ptProbe = MoveProbePointToRawFaces( Info.ptProbe, Info.vtProbe, nPartId) -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) local nIdLine = EgtLinePVL( nAddGrpId, Info.ptProbe, Info.vtProbe, 10, GDB_RT.GLOB) -- TODO lunghezza da portare fuori come parametro local Machinings = GetMachinings( MCH_MY.PROBING, Info.sType) -- se c'è almeno una lavorazione, allora devo fare tastatura if Machinings and #Machinings > 0 then local sProbing = GetProbingMachining( Machinings, Info.sHead) -- se c'è la linea e la lavorazione, applico if sProbing and nIdLine then local sName = 'DtMtProbe_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sProbing.Name) -- si inverte la direzione della linea, deve essere entrante, oppostaa vettore estrusione EgtInvertCurve( nIdLine) -- aggiungo geometria EgtSetMachiningGeometry( {{ nIdLine, -1}}) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr else bOk = true end else bOk = false sErr = 'Error on probing' end -- altrimenti tastatura non richiesta, esco else return true end else bOk = false sErr = 'Error on probing' end return bOk, sErr end --------------------------------------------------------------------- return ProcessProbing