From c418f5b92ac3aea3437112ddf8d2aefc83620f22 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Tue, 5 Mar 2024 11:32:18 +0100 Subject: [PATCH] =?UTF-8?q?In=20Mortise.Make:=20Aggiunta=20possibilit?= =?UTF-8?q?=C3=A0=20di=20inserire=20lavorazione=20di=20smusso?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/ProcessMortise.lua | 92 +++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 5cfa542..05cbddd 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -15,6 +15,7 @@ -- 2023/08/10 Modificata scelta SCC per tasche in Y+/- in coda o quasi. -- 2024/01/18 Implementata GetBlockedAxis che gestisce gli assi bloccati per tutti i tipi di utensile. -- 2024/02/28 Forzata SPIRAL_IN se c'è anche un solo lato aperto +-- 2024/03/05 Aggiunta possibilità di inserire lavorazione di smusso -- Tabella per definizione modulo local ProcessMortise = {} @@ -30,6 +31,9 @@ EgtOutLog( ' ProcessMortise started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') +-- variabili assegnazione parametri Q +local Q_DEPTH_CHAMFER = 'Q02' -- d + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessMortise.Identify( Proc) @@ -277,7 +281,36 @@ function ProcessMortise.VerifyMortiseOrPocket( Proc, dDiam, dDepth, dMaxTotLen, return sPocketing, dMaxDepth, dToolDiam end - --------------------------------------------------------------------- +--------------------------------------------------------------------- +local function VerifyChamfer( Proc, AuxId, nRawId, bMakeVertCham, bDownHead) + local nChamfer = 0 + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- verifico che lo smusso sia richiesto + local dDepth = EgtGetInfo( Proc.Id, Q_DEPTH_CHAMFER, 'd') or 0 + if dDepth > 0 then + nChamfer = 1 + end + + -- recupero la lavorazione + local sMilling + if nChamfer > 0 then + if bDownHead then + sMilling = ML.FindMilling( 'Mark_H2', nil, nil, nil, nil, false, true) + else + sMilling = ML.FindMilling( 'Mark') + end + if not sMilling then + local sErr = 'Error : Mark not found in library' + EgtOutLog( sErr) + return -1, 0, sErr + end + end + + return nChamfer, dDepth, sMilling +end + +--------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- ingombro del pezzo @@ -405,6 +438,63 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local bPockUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) local bPockDown = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.174) local bPockAngTrasm = ( BD.ANG_TRASM and vtExtr:getZ() < -0.1) + + -- recupero i dati della curva e del profilo + local dDepth = dMorH + local bDownHead = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.1) + local bToolInv = ( not bDownHead and vtExtr:getZ() < -0.1 and b3Aux:getDimZ() > b3Raw:getDimZ() - 5) + local dExtra = 2 + + -- verifico se servono gli smussi. Se lavorazione principale di svuotatura significa che è solo da un lato + -- generalmente sono lavorazioni non molto lunghe, quindi non si gestistono gli step + -- verifico i parametri Q per profondità smusso e per eseguirlo in esclusiva + local nChamfer, dDepthCham, sChamfer = VerifyChamfer( Proc, AuxId, nRawId, true) + -- se devo inserire il chamfer + if nChamfer > 0 and Proc.Grp ~= 0 and dDepth > dDepthCham then + -- inserisco la lavorazione + local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sNameCh, sChamfer) + if not nMchId then + local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + if not bToolInv then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + -- assegno affondamento e offset radiale + EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - dMorH) + EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) + -- posizione braccio porta testa + local nSCC = MCH_SCC.NONE + if not BD.C_SIMM then + if Proc.Head then + nSCC = MCH_SCC.ADIR_XP + elseif Proc.Tail then + nSCC = MCH_SCC.ADIR_XM + elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + nSCC = MCH_SCC.ADIR_YP + elseif vtExtr:getY() > -0.01 then + nSCC = MCH_SCC.ADIR_YP + else + nSCC = MCH_SCC.ADIR_YM + end + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + -- recupero la lavorazione local sPockType = 'Mortise' local sMchExt = ''