diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index 6ee6d8d..3d77ec7 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -1,8 +1,10 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2023/03/09 +-- ProcessTenon.lua by Egaltech s.r.l. 2023/03/28 -- Gestione calcolo tenone a coda di rondine per Travi -- 2021/04/08 Aggiunto controllo massimo materiale lavorabile dalla fresa. -- 2022/04/14 Aumentati un poco i limiti di orientamento verso il basso per FAST e PF. -- 2023/02/08 Aumentato il range per cui i tenoni vengono lavorati in sottosquadro. +-- 2023/03/27 Migliorate condizioni scelta pretaglio con lama o fresa; gestione unificata con ProcessTenon. +-- 2023/03/28 Corretta gestione faccia di base quando divisa in più parti per distanza massima da lavorare. -- Tabella per definizione modulo local ProcessDtTenon = {} @@ -10,6 +12,7 @@ local ProcessDtTenon = {} -- Include require( 'EgtBase') local BL = require( 'BeamLib') +local Fbp = require( 'FaceByPocket') local Cut = require( 'ProcessCut') EgtOutLog( ' ProcessTenon started', 1) @@ -167,6 +170,9 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- ne determino l'asse local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB) vtAx:normalize() + -- abilitazione lavorazione da sotto + local bMillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) + local bMillDown = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.174) -- se tenone inclinato o non esattamente alle estremità, necessario taglio di lama sulla testa if not AreSameOrOppositeVectorApprox( vtN, X_AX()) or ( Proc.Box:getMax():getX() < b3Raw:getMax():getX() - dOvmHead - 100 * GEO.EPS_SMALL and @@ -183,44 +189,17 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if AddId then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) - -- se pezzo piccolo, in coda e piano inclinato attorno a Z applico svuotatura - if b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getX() < 0 and abs( vtExtr:getY()) > 0.173 then - local sPocketing = ML.FindPocketing( 'OpenPocket') - local dMaxDepth = 100 - local dStep = 30 - local nSurfStep - -- acquisisco i dati necessari dall'utensile - if EgtMdbSetCurrMachining( sPocketing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dStep - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end - end - -- acquisisco elevazione - local dElev = BL.GetFaceElevation( AddId, 0, nPartId) - nSurfStep = ceil( dElev / dMaxDepth) - dSurfStep = dElev / nSurfStep - local bOk = true - local sErr - -- copio superfice al passo superfice e ci applico la lavorazione - for i = nSurfStep, 2, -1 do - local nAddIdTmp = EgtSurfTmPlaneInBBox( nAddGrpId, ptC+((dSurfStep*(i-1))*vtN), vtN, b3Solid, GDB_RT.GLOB) - if nAddIdTmp then - EgtSetName( nAddIdTmp, 'AddCut_' .. tostring( Proc.Id)) - EgtSetInfo( nAddIdTmp, 'TASKID', Proc.TaskId) - -- aggiungo lavorazione - bOk, sErr = ApplyPocket( Proc, sPocketing, i, (dSurfStep + 0), nAddIdTmp, vtExtr) - if not bOk then - break - end - end - end - if not bOk then + -- solo per macchine tipo PF e simili: se pezzo piccolo, in coda, piano inclinato attorno a Z e inclinato verso il basso applico svuotatura + if b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getX() < 0 and abs( vtExtr:getY()) > 0.173 and vtExtr:getZ() < -0.1 and BD.C_SIMM then + -- recupero la lavorazione + local sPocketing = ML.FindPocketing( 'OpenPocket', nil, nil, nil, not bMillDown, bMillDown) + if not sPocketing then + local sErr = 'Error : pocketing '..sPockType..' not found in library' + EgtOutLog( sErr) return false, sErr end - -- faccio ultima superfice - bOk, sErr = ApplyPocket( Proc, sPocketing, 1, EgtIf( nSurfStep > 1, ( dSurfStep + 0), 0), AddId, vtExtr) + -- eseguo le svuotature necessarie + local bOk, sErr = Fbp.Make( Proc, AddId, 0, sPocketing, nPartId, b3Solid) if not bOk then return false, sErr end @@ -234,9 +213,6 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end end 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 = 'DtTenon' local sMilling = ML.FindMilling( sMillType .. EgtIf( bMillDown, '_H2', ''), nil, nil, nil, nil, bMillUp, bMillDown) @@ -265,22 +241,29 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) return false, sErr end -- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0) - local dMaxDist = 0 - local nLoopId, nLoopCnt = EgtExtractSurfTmFacetLoops( Proc.Id, 0, EgtGetParent( Proc.Id)) - if nLoopId then - local dUmin, dUmax = EgtCurveDomain( nLoopId) - for dU = dUmin, dUmax do - local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT) - local ptNear = EgtNP( AuxId, ptP, GDB_ID.ROOT) - local dDist = dist( ptP, ptNear) - if dDist > dMaxDist then - dMaxDist = dDist + local dMaxDist + for i = 0, Proc.Fct - 1 do + local ptFC, vtFN = EgtSurfTmFacetCenter( Proc.Id, i, GDB_ID.ROOT) + if not AreSameVectorApprox( vtFN, vtN) or abs( ( ptFC - ptBC) * vtN) > 100 * GEO.EPS_SMALL then + break + end + local nLoopId, nLoopCnt = EgtExtractSurfTmFacetLoops( Proc.Id, i, EgtGetParent( Proc.Id)) + if nLoopId then + local dUmin, dUmax = EgtCurveDomain( nLoopId) + for dU = dUmin, dUmax do + local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT) + local ptNear = EgtNP( AuxId, ptP, GDB_ID.ROOT) + local dDist = dist( ptP, ptNear) + if not dMaxDist or dDist > dMaxDist then + dMaxDist = dDist + end + end + for j = 1, nLoopCnt do + EgtErase( nLoopId + j - 1) end end - for i = 1, nLoopCnt do - EgtErase( nLoopId + i - 1) - end - else + end + if not dMaxDist then local b3DtAux = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frDtTen) dMaxDist = 2 * ( b3DtTen:getRadius() - b3DtAux:getRadius()) end diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 437b9e7..e8090e4 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2023/03/09 +-- ProcessTenon.lua by Egaltech s.r.l. 2023/03/27 -- Gestione calcolo tenone per Travi -- 2021/10/04 Corretto calcolo HCING per pezzi piccoli. -- 2022/02/15 Aggiornata VerifyOrientation per macchine con testa da sotto. @@ -9,6 +9,7 @@ -- 2022/12/12 Su macchine con rulli pressori e pinze separate si riduce di meno l'ingombro con tenoni inclinati. -- 2022/12/20 Aggiunta gestione smusso. Migliorata scelta tra sopra e sotto per il punto di inizio. In VerifyOrientation aggiunta trave medio alta. -- 2023/01/20 Modificata scelta lato di attacco per pezzo piccolo su macchine con pinza speciale (pinza 5). +-- 2023/03/27 Migliorate condizioni scelta pretaglio con lama o fresa; gestione unificata con ProcessDtTenon. Migliorato calcolo altezza tenone. -- Tabella per definizione modulo local ProcessTenon = {} @@ -128,8 +129,8 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- determino altezza del tenone local frTen = Frame3d( ptBC, vtExtr) - local b3Ten = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTen) - local dTenH = b3Ten:getDimZ() + local b3Ten = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTen) + local dTenH = b3Ten:getMax():getZ() -- assegno centro e normale della faccia top local vtN = vtExtr local ptC = ptBC + vtN * dTenH @@ -180,11 +181,10 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if AddId then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) - -- se pezzo piccolo, in coda, con piano inclinato verso il basso e macchina con testa da sotto applico svuotatura - if bShortPart and vtExtr:getX() < 0 and vtExtr:getZ() < -0.09 and BD.DOWN_HEAD then + -- solo per macchine tipo PF e simili: se pezzo piccolo, in coda, piano inclinato attorno a Z e inclinato verso il basso applico svuotatura + if b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getX() < 0 and abs( vtExtr:getY()) > 0.173 and vtExtr:getZ() < -0.1 and BD.C_SIMM then -- recupero la lavorazione - local sPockType = EgtIf( bMillDown, 'OpenPocket_H2', 'OpenPocket') - local sPocketing = ML.FindPocketing( sPockType, nil, nil, nil, not bMillDown, bMillDown) + local sPocketing = ML.FindPocketing( 'OpenPocket', nil, nil, nil, not bMillDown, bMillDown) if not sPocketing then local sErr = 'Error : pocketing '..sPockType..' not found in library' EgtOutLog( sErr)