-- ProcessMortise.lua by Egaltech s.r.l. 2019/03/22 -- Gestione calcolo mortase a coda di rondice per Travi -- Tabella per definizione modulo local ProcessDtMortise = {} -- Include require( 'EgtBase') EgtOutLog( ' ProcessDtMortise started', 1) -- Dati local BD = require( 'BeamData') local Millings = require( 'MillingData') --------------------------------------------------------------------- local function FindMilling( sType) for i = 1, #Millings do local Milling = Millings[i] if Milling.Type == sType then return i, Milling.Name end end return 0 end --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessDtMortise.Identify( Proc) return ( (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 55) or (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 56)) end --------------------------------------------------------------------- -- Classificazione della feature function ProcessDtMortise.Classify( Proc) -- recupero i dati della faccia di fondo local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) -- verifico sia una superficie if not vtN then return false end -- verifico se la mortasa è lavorabile solo da sotto local bDown = ( vtN:getZ() < - 0.1) return true, bDown end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr end -- recupero i dati della curva e del top local dDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, 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) .. ' DtMortise from bottom impossible' EgtOutLog( sErr) return false, sErr end -- recupero la lavorazione local nMill, sMilling = FindMilling( 'DtMortise') if not sMilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' EgtOutLog( sErr) return false, sErr end -- recupero il diametro dell'utensile local dToolDiam = 50 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam end end -- verifico se necessarie più passate local dDist = dist( EgtSP( AuxId, GDB_RT.GLOB), EgtEP( AuxId, GDB_RT.GLOB)) if dDist < dToolDiam + 0.5 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Dt mortise too narrow' EgtOutLog( sErr) return false, sErr end local nPass = ceil( dDist / ( 1.9 * dToolDiam)) local dStep = ( dDist - 0.95 * dToolDiam) / ( 2 * nPass) for i = nPass, 1, -1 do -- inserisco la lavorazione di contornatura local sNameF = 'DtMt_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nPass) local nMchFId = EgtAddMachining( sNameF, sMilling) if not nMchFId then local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- imposto offset local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end end return true end --------------------------------------------------------------------- return ProcessDtMortise