From 45afa144ad732bf5db05c0d5906a4a07eee99e43 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 23 Aug 2022 18:19:44 +0200 Subject: [PATCH] Feature/MarkingInFreeContour: In FreeContour aggiunta la gestione dell'utensile penna per P13=10 --- LuaLibs/ProcessFreeContour.lua | 81 +++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 4b438e7..dda6f57 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -1,5 +1,6 @@ -- ProcessFreeContour.lua by Egaltech s.r.l. 2021/10/07 -- Gestione calcolo profilo libero per Travi +-- 2022/08/23 Aggiunta la funzione MakeByMark per la gestione del caso P13=10 -- Tabella per definizione modulo local ProcessFreeContour = {} @@ -690,6 +691,76 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) return true end +--------------------------------------------------------------------- +local function MakeByMark( Proc, nRawId, b3Raw, nPartId) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls 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 e verifico l'entità curva + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 + if AuxId then AuxId = AuxId + Proc.Id end + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then + local sErr = 'Error : missing profile geometry' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati della curva e del profilo + local dDepth = abs( EgtCurveThickness( AuxId)) + local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + local bToolInv = ( vtExtr:getZ() < -0.1 and b3Aux:getDimZ() > b3Raw:getDimZ() - 5) + -- verifico che la marcatura non sia orientata verso il basso (-5 deg) + if vtExtr:getZ() < - 0.1 and not BD.DOWN_HEAD and not BD.TURN then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mark from bottom impossible' + EgtOutLog( sErr) + return false, sErr + end + -- abilitazione lavorazione da sotto + local bMillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) + local bMillDown = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.174) + -- recupero la lavorazione + local sMillType = 'Text' + --local sMchExt = EgtIf( bMillDown, '_H2', '') + local sMilling = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown) + if not sMilling then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- inserisco la lavorazione + local sName = 'FreeMark_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, sMilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchId, 'Part', Proc.PartId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- se estrusione da sotto, inverto direzione fresa + if bToolInv then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + end + -- posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_ZP + if AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP) + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + return true +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) @@ -700,7 +771,15 @@ function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) return MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) -- altrimenti contornatura else - return MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- recupero il tipo di lavorazione + local nCntType = EgtGetInfo( Proc.Id, 'CNT_TYPE', 'i') or 0 + -- se marcatura + if nCntType == 10 then + return MakeByMark( Proc, nRawId, b3Raw, nPartId) + -- se fresatura + else + return MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) + end end end