From bf8e0a6d5d27afa9d8f99cace403557b59daff71 Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 24 Sep 2021 11:17:27 +0200 Subject: [PATCH] DataBeam : - Gestione migliorata lavorazioni BH (blockhaus) su macchina Fast BH. --- LuaLibs/ProcessLapJoint.lua | 122 ++++++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 27 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 465daa6..ffd3c41 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2021/09/08 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2021/09/23 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. -- 2021/01/24 Con sega a catena ora sempre impostato asse A. @@ -23,6 +23,8 @@ -- 2021/09/08 Aggiunta gestione parametro Q04 per i tagli di lama lungo facce lunghe (con o senza facce di chiusura) -- 2021/09/21 Aggiunta lavorazione/opzione "lamello" con le feature 16, 30, 32, 39, -- che si attiva abilitando il check al tipo milling: SideMillAsBlade (SideMillAsBlade_2) +-- 2021/09/23 Gestione migliorata lavorazioni BH (blockhaus) su macchina fast BH, +-- migliorata applicazione lavorazioni BH su feature lunghe lavorte a passi -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -311,22 +313,75 @@ local function VerifyPocket( Proc, dDiam, dDepth, dMaxTotLen, sMchFindMaster) end --------------------------------------------------------------------- -local function VerifyBHSideMill( Proc) +local function VerifyBHSideMill( Proc, bMasterIsU, bMasterIsL, bSinglePart, bPrevBhSideMill) + local bUseBHSideMill = false local bHead = true local bHeadDir = true local sMilling - local dMaxMat = 10 + local dThickTool = 0 local dToolDiam = 0 - -- se non feature BlockHausHalfLap o non abilitato parametro Q per lavorarlo di fianco esco + -- 22/09/2021 Su richiesta di Alessandro Sola, si toglie la richiesta di presenza del parametro Q per poter applicare + -- la lavorazione su più features( che non hanno questo parametro Q), quindi questa lavorazione viene verificata se è abilitato il parametro utensile + -- che ooviamente tramite la lavorazione è abbinata alla lista lavorazioni con BHSideMill. + -- Al fine di mantenere il funzionamento precedente (purtroppo non sono stati descritti i motivi del confrontare il parametro Q) + -- si elude il controllo del Q solo se la variabile del Beamdata BD.BH_MACHINE segnala che non è una macchina tipo BH (ha la fresa blockhaus al posto della lama) + + -- se non feature BlockHausHalfLap o non abilitato parametro Q per lavorarlo di fianco esco local nUseSideTool = EgtGetInfo( Proc.Id, Q_SIDE_ROUGH_TOOL, 'i') or 0 - if Proc.Prc ~= 37 and nUseSideTool == 0 then + if Proc.Prc ~= 37 and nUseSideTool == 0 and not BD.BH_MACHINE then return false end -- verifico se U - local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc)) + local bIsU + local bIsL + + if bMasterIsU ~= nil then + bIsU = bMasterIsU + else + bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc)) + end + if bMasterIsL ~= nil then + bIsL = bMasterIsL + else + -- verifico se due facce o L con una o due facce di terminazione + bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) + end + -- recupero l'ingombro della trave + local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + -- verifico se la funzione è lanciata da IsTailFeature o Classify + if bSinglePart == nil then + -- se lunghezza non richiede spezzatura setto la variabile bSinglePart per non fare con fresa BH + -- perchè deve avere almeno 2 facce + if not( ( Proc.Box:getDimX() > BD.LONGCUT_MAXLEN) or + ( Proc.Box:getDimX() > 0.8 * b3Solid:getDimX() and Proc.Box:getDimX() > BD.LONGCUT_ENDLEN)) then + bSinglePart = true + end + end + -- ad oggi 22/09/2021 la lavorazione BH non va bene se le facce di chiusura non sono perpendicolari a X, quindi + -- se non sono perpendicolari non si applica la lavorazione BH + if bIsU or bIsL then + local bExit = false + for i = 1, Proc.Fct do + local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) + if abs(vtN:getX()) > 0.001 and abs(vtN:getX()) < 0.999962 then + bExit = true + break + end + end + if bExit then + return false + end + end + + -- se forma a U o L verifico che -- se U e lunghezza non richiede spezzatura - if bIsU and Proc.Box:getDimX() <= BD.LONGCUT_MAXLEN then + if ( bIsU or bIsL or ( Proc.Fct == 1 and not bSinglePart) ) and Proc.Box:getDimX() <= BD.LONGCUT_MAXLEN then + -- se faccia singola di un passo multiplo e risultato precedente non applicato, riporto il risultato del passo precedente + if ( bIsU or bIsL or ( Proc.Fct == 1 and not bSinglePart) ) and bPrevBhSideMill ~= nil and not bPrevBhSideMill then + return false + end -- recupero la lavorazione sMilling = ML.FindMilling( 'BHSideMill') if sMilling then @@ -339,13 +394,10 @@ local function VerifyBHSideMill( Proc) dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + dThickTool = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThickTool end end -- verifico se la feature è abbastanza vicino a testa/coda da permettere la lavorazione con questo utensile - -- recupero l'ingombro della trave - local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if b3Solid then local dMinXF = Proc.Box:getMin():getX() local dMaxXF = Proc.Box:getMax():getX() @@ -355,6 +407,10 @@ local function VerifyBHSideMill( Proc) bHeadDir = ( dMaxT - dMinXF) < ( dMaxXF - dMinT) + 50 bHead = bHeadDir -- determino se è compatibile con il massimo affondamento dell'utensile + -- nota F.M il 22/09/2021: non sarebbe meglio utilizzare lo spessore lama invece della massima lavorazione? + -- questo perchè Alessandro ha settato il parametro Max Material a 80 con spessore lama 42 + -- se invece il Max material viene usato per definire fino a che affondamento (lungo l'asse utensile) + -- può arrivare prima di collidere con la testa allora si può utilizzare il dMaxDepth bUseBHSideMill = EgtIf( bHead, ( dMaxT - dMinXF), ( dMaxXF - dMinT)) < dMaxDepth -- se diametro maggiore della testa if BD.HEAD_DIM_FOR_BH and dToolDiam > BD.HEAD_DIM_FOR_BH then @@ -364,7 +420,7 @@ local function VerifyBHSideMill( Proc) end end end - return bUseBHSideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam + return bUseBHSideMill, bHead, bHeadDir, sMilling, dThickTool, dToolDiam end --------------------------------------------------------------------- @@ -530,7 +586,7 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) AssignQIdent( Proc) -- se può essere fatto con utensile tipo lama local bUseBHSideMill, bHead, bHeadDir = VerifyBHSideMill( Proc) - if bUseBHSideMill then + if bUseBHSideMill then Proc.HeadDir = bHeadDir return not bHead end @@ -666,7 +722,8 @@ function ProcessLapJoint.Classify( Proc, b3Raw) local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se può essere fatto con utensile tipo lama local bUseBHSideMill, _, _, _, dMaxMat = VerifyBHSideMill( Proc) - if bUseBHSideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then +-- if bUseBHSideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then + if bUseBHSideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then return true, false -- altrimenti controllo se deve essere ruotato con le altre lavorazioni else @@ -4213,7 +4270,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end --------------------------------------------------------------------- -local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart) +local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill) local sWarn -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) @@ -4388,18 +4445,26 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- verifico se due facce o L con una o due facce di terminazione local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia - local bMakeBySideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam = VerifyBHSideMill( Proc) - if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then + local bMakeBySideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam = VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill) + if bPrevBhSideMill == nil then + bPrevBhSideMill = bMakeBySideMill + end +-- if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then + if bMakeBySideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo if nChamfer < 2 then - -- recupero la larghezza della faccia perpendicolarmente alle altre 2 - local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT) - local vtX = vtN2 ^ vtN - local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2) - local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef) - if b3Ref then - dV = b3Ref:getDimY() - dH = b3Ref:getDimX() + if Proc.Fct > 1 then + -- recupero la larghezza della faccia perpendicolarmente alle altre 2 + local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT) + local vtX = vtN2 ^ vtN + local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2) + local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef) + if b3Ref then + dV = b3Ref:getDimY() + dH = b3Ref:getDimX() + end + else + dH, dV = dV, dH end -- se lavorazione da sotto e lunga, va divisa in due metà local bDouble = ( vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200)) @@ -5153,7 +5218,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end end - return true, sWarn + return true, sWarn, bPrevBhSideMill end --------------------------------------------------------------------- @@ -5189,11 +5254,14 @@ local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- applico le lavorazioni sulle diverse parti local sWarn + local bPrevBhSideMill for i = 1, #vAddId do local b3Box = EgtGetBBoxGlob( vAddId[i], GDB_BB.STANDARD) local nFct = EgtSurfTmFacetCount( vAddId[i]) local AddProc = { Id = vAddId[i], Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Box, Fct = nFct, Flg = Proc.Flg} - local bOk, sMyWarn = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, dOvmHead, false) + -- lasciare il false nel sesto parametro (perchè internamente viene verificato se diverso da nil) + local bOk, sMyWarn + bOk, sMyWarn, bPrevBhSideMill = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, dOvmHead, false, bPrevBhSideMill) if not sWarn then sWarn = sMyWarn end if not bOk then return bOk, sWarn end end