diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 3eec184..4163a5e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -14,6 +14,8 @@ -- 2022/05/18 Correzioni e migliorie a PutStartNearestToEdge. -- 2022/06/25 Rese globali le funzioni GetChainSawBlockedAxis e GetChainSawInitAngs prima in ProcessLapJpoint. -- 2022/07/12 A GetFaceHvRefDim aggiunta possibilità di confronto e limitazione dimensioni con grezzo/pezzo (conta solo la sezione). +-- 2022/07/26 Aggiunta la funzione FindFaceBestOrientedAsAxis, precedentemente in ProcessLapJoint +-- 2022/07/26 Alla funzione FindFaceBestOrientedAsAxis aggiunta la possibilità di escludere una faccia dalla ricerca -- Tabella per definizione modulo local BeamLib = {} @@ -794,5 +796,23 @@ function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) end end +--------------------------------------------------------------------- +-- Trova l'Ind (0 based) della faccia meglio orientata come l'asse vtAx. Restituisce anche vtN e ptC della faccia stessa. La faccia di indice (0 based) fctExclude non viene considerata nella ricerca. +function BeamLib.FindFaceBestOrientedAsAxis( Proc, vtAx, fctExclude) + local nFaceIndMax = 0 + local dMaxComp = 0 + fctExclude = fctExclude or -1 + for i = 1, Proc.Fct do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) + local dComp = abs( vtN * vtAx) + if dComp > dMaxComp and i ~= fctExclude + 1 then + nFaceIndMax = i -1 + dMaxComp = dComp + end + end + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFaceIndMax, GDB_ID.ROOT) + return nFaceIndMax, ptC, vtN +end + ------------------------------------------------------------------------------------------------------------- return BeamLib diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index c519364..d0032f5 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4338,23 +4338,6 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, return true, sMyWarn end ---------------------------------------------------------------------- --- Trova l'Ind (0 based) della faccia meglio orientata come l'asse vtAx. Restituisce anche vtN e ptC della faccia stessa. -local function FindFaceBestOrientedAsAxis( Proc, vtAx) - local nFaceIndMax = 0 - local dMaxComp = 0 ; - for i = 1, Proc.Fct do - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) - local dComp = abs( vtN * vtAx) - if dComp > dMaxComp then - nFaceIndMax = i -1 - dMaxComp = dComp - end - end - local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFaceIndMax, GDB_ID.ROOT) - return nFaceIndMax, ptC, vtN -end - --------------------------------------------------------------------- local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill, bAllWithEndCap) if not BD.MAXDIAM_POCK_CORNER then @@ -5137,7 +5120,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local bOrthoFacesMaster = nil local bSetOpenBorders = nil -- trovo la faccia con normale più inclinata verso Y - local nFacApproxY, ptCFacApproxY, vtNFacApproxY = FindFaceBestOrientedAsAxis( Proc, Y_AX()) + local nFacApproxY, ptCFacApproxY, vtNFacApproxY = BL.FindFaceBestOrientedAsAxis( Proc, Y_AX()) -- se Q03 = 2 e -- 3 facce a L, oppure -- 3 facce non a L ma con una faccia favorevole a Y, oppure diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index e9e30b2..f539e6c 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -2,6 +2,7 @@ -- Gestione calcolo mortase per Travi -- 2021/07/20 Aggiunta gestione rinvio angolare su FAST. -- 2021/12/01 Se frontale aggiungo taglio con Grp e Proc di vero taglio (per aggiornare ingombro di testa /coda). +-- 2022/07/26 Aggiunta gestione del parametro P04=1 per la pulizia degli angoli con mortasatrice (sega a catena) specifica -- Tabella per definizione modulo local ProcessMortise = {} @@ -79,6 +80,106 @@ function ProcessMortise.GetCutPlane( Proc) end --------------------------------------------------------------------- +-- Aggiunge la lavorazione di pulizia angoli + local function AddCleanCornersMachining( nProcId, sMortising, nWorkFaceInd, vtN) + local sName = 'Mort_' .. ( EgtGetName( nProcId) or tostring( nProcId)) .. '_CleanCorners1' + local nMchFId = EgtAddMachining( sName, sMortising) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMortising + EgtOutLog( sErr) + return false, sErr + end + sName = EgtGetOperationName( nMchFId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nProcId, nWorkFaceInd}}) + local nFaceUse = BL.GetNearestParalOpposite( vtN) + local vtOrtho = BL.GetVersRef( nFaceUse) + -- imposto angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 1)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) + -- imposto uso del lato faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- applico il parametro plunge, che setta la lavorazione per affondare solamente, senza lavorare tutto il contorno; 1: solo lato iniziale, 2: solo lato finale, 3: entrambi + sNotes = 'Plunge=3;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + if not ML.ApplyMachining( true, false) then + if EgtGetOutstrokeInfo() then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + -- impostazione alternativa angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 2)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 2)) + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + if EgtIsMachiningEmpty() then + _, sWarn = EgtGetMachMgrWarning( 0) + EgtSetOperationMode( nMchFId, false) + return false, sWarn + end + return true, sWarn + end + +--------------------------------------------------------------------- +-- Pulizia angoli nel caso sia settato il parametro P04=1 +local function CleanCorners( Proc, dMorH, vtN, bOpenBtm) + -- verifico se è attiva la pulizia + local bCleanCorners = ( EgtGetInfo( Proc.Id, 'P04', 'i') == 1 and Proc.Prc ~= 51) + -- cerco la lavorazione adatta + local sMortisingCleanCorners = ML.FindSawing( 'Mortising') + if bCleanCorners and sMortisingCleanCorners then + local dSawWidth = 50 + local dSawThick = 12 + local dMaxDepth = 200 + -- se non trova la lavorazione non faccio nulla + if not sMortisingCleanCorners then + local sWarn = 'Warning: mortising tool not found, square tenon finishing skipped' + EgtOutLog( sWarn) + return true, sWarn + else + -- recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sMortisingCleanCorners) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawWidth = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawWidth + dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- al momento se l'utensile non arriva salto la lavorazione + local dFullMorH = EgtIf( bOpenBtm, dMorH * 2, dMorH) + if dFullMorH > dMaxDepth + 10 * GEO.EPS_SMALL then + local sErr = 'Error in Mortise : elevation (' .. EgtNumToString( dFullMorH, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + EgtOutLog( sErr) + return false, sErr + end + -- cerco le due facce migliori da lavorare + local nWorkFaceInd, _, _ = BL.FindFaceBestOrientedAsAxis( Proc, vtN ^ X_AX()) + local nWorkFaceInd2, _, _ = BL.FindFaceBestOrientedAsAxis( Proc, vtN ^ X_AX(), nWorkFaceInd) + -- lavoro la prima faccia + local bOk1, sErr = AddCleanCornersMachining( Proc.Id, sMortisingCleanCorners, nWorkFaceInd, vtN) + -- lavoro la seconda faccia + local bOk2, sErr2 = AddCleanCornersMachining( Proc.Id, sMortisingCleanCorners, nWorkFaceInd2, vtN) + if sErr2 then + if not sErr then sErr = '' end + if sErr ~= sErr2 then + sErr = EgtIf( #sErr > 0, sErr .. '\n' .. sErr2, sErr2) + end + end + if not bOk1 or not bOk2 then + return false, sErr + end + return true, sErr + end + end +end + + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- ingombro del pezzo @@ -326,6 +427,12 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- verifico se necessaria la pulizia degli angoli ( tenone ad angoli non raggiati) e applico nel caso + local _, sWarn2 = CleanCorners( Proc, dMorH, vtN, bOpenBtm) + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end -- Se non c'è il fondo e la lavorazione non ha lavorato tutta la superficie per limite altezza utensile -- inserisco una ulteriore lavorazione contraria if bOpenBtm and not bForceOneSide and nDepthMin and abs(nDepthMin) > 0 then