From c14b77c9cdabca4fa2495917b86d971a0f5d8cf5 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 18 Mar 2020 22:10:48 +0000 Subject: [PATCH] DataBeam : - in contorni liberi gestite fresature parziali non fattibili da sotto - aggiunti antischeggia in mortase a coda di rondine - migliorie varie. --- LuaLibs/BeamExec.lua | 4 +- LuaLibs/MachiningLib.lua | 8 ++- LuaLibs/ProcessDtMortise.lua | 109 +++++++++++++++++++++++++++++- LuaLibs/ProcessFreeContour.lua | 49 +++++--------- LuaLibs/ProcessProfConcave.lua | 6 +- LuaLibs/ProcessProfConvex.lua | 6 +- LuaLibs/ProcessProfHead.lua | 6 +- LuaLibs/ProcessStepJointNotch.lua | 45 +++++++----- 8 files changed, 169 insertions(+), 64 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 661f49d..06725bb 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2020/02/14 +-- BeamExec.lua by Egaltech s.r.l. 2020/03/18 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -566,7 +566,7 @@ local function ClassifyFeatures( vProc, b3Raw, Stats) bOk, bDown = RoundArch.Classify( Proc) -- se contorno libero elseif FreeContour.Identify( Proc) then - bOk, bDown = FreeContour.Classify( Proc) + bOk, bDown = FreeContour.Classify( Proc, b3Raw) -- se decorazione elseif Decor.Identify( Proc) then bOk, bDown = Decor.Classify( Proc) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index f7b253d..c742c42 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1,4 +1,4 @@ --- MachiningLib.lua by Egaltech s.r.l. 2020/02/26 +-- MachiningLib.lua by Egaltech s.r.l. 2020/03/18 -- Libreria ricerca lavorazioni per Travi -- Tabella per definizione modulo @@ -38,12 +38,14 @@ function MachiningLib.FindCutting( sType) end --------------------------------------------------------------------- -function MachiningLib.FindMilling( sType, dDepth) +function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr) for i = 1, #Millings do local Milling = Millings[i] if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then + local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID) local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - if not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL then + if ( not sTuuidMstr or sTuuidMstr == sTuuid) and + ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) then return Milling.Name end end diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index e01088c..aa05f47 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessMortise.lua by Egaltech s.r.l. 2020/02/06 +-- ProcessMortise.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo mortase a coda di rondice per Travi -- Tabella per definizione modulo @@ -10,9 +10,13 @@ require( 'EgtBase') EgtOutLog( ' ProcessDtMortise started', 1) -- Dati +local BL = require( 'BeamLib') local BD = require( 'BeamData') local ML = require( 'MachiningLib') +-- settaggi interni ( poi andrà utilizzato parametro ACTIVE_AS proveniente da parametri utente di TechnoEssetre) +local bMakeAntiSplitPath = true + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessDtMortise.Identify( Proc) @@ -63,8 +67,107 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- recupero la lavorazione - local sMilling = ML.FindMilling( 'DtMortise') + local sMillingAs + -- se parametro interno abilitato e il percorso non è chiuso, aggiungo percorso e lavorazione antischeggia + if bMakeAntiSplitPath and not EgtCurveIsClosed( AuxId) then + -- recupero la lavorazione + sMillingAs = ML.FindMilling( 'DtMortise') + if not sMillingAs then + local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- recupero il diametro dell'utensile + local dToolDiam = 100 + if EgtMdbSetCurrMachining( sMillingAs) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + end + end + -- recupero punto iniziale e finale del percorso + local pStartP = EgtSP( AuxId, GDB_RT.GLOB) + local pEndP = EgtEP( AuxId, GDB_RT.GLOB) + if pStartP and pEndP then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + + local pMid = ( pStartP + pEndP) / 2 + local dDistMid = dist( pStartP, pMid) + local pMidArc + local bGoodArc + local nDiv = 2 + local nId1 + -- ciclo fino ad individuare arco compativile con l'utensile + while not bGoodArc do + -- linea dal punto medio alla fine + nId1 = EgtLine( nAddGrpId, pMid, pEndP, GDB_RT.GLOB) + -- se è stata creata setto il piano e l'accorcio + if nId1 then + -- EgtModifyCurveExtrusion( nId1, vtExtr, GDB_RT.GLOB) + -- accorcio la seconda linea al valore impostato, partendo dal divisore 2 + EgtTrimExtendCurveByLen( nId1, -( dDistMid * ( 1 - ( 1 / nDiv))), pEndP, GDB_RT.GLOB) + -- ruoto di -90 gradi + EgtRotate( nId1, pMid, vtExtr, -90, GDB_RT.GLOB) + -- prendo il punto finale dell'entità ruotata + pMidArc = EgtEP( nId1, GDB_RT.GLOB) + -- cancello linea + EgtErase(nId1) + -- creo arco per 3 punti + nId1 = EgtArc3P( nAddGrpId, pStartP, pMidArc, pEndP, GDB_RT.GLOB) + if nId1 then + EgtModifyCurveExtrusion( nId1, vtExtr, GDB_RT.GLOB) + -- recupero il raggio e lo comparo con il raggio utensile, + -- se è maggiore del raggio utensile esco dal cliclo + local dRad = EgtArcRadius( nId1) + if dRad > 0 and dRad > dToolDiam then + bGoodArc = true + else + -- cancello l'arco e incremento il componente del divisore + EgtErase(nId1) + nDiv = nDiv + 1 + end + else + bGoodArc = true + end + else + bGoodArc = true + end + end + if not nId1 then + local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- inserisco la lavorazione di contornatura anti splint + local sNameF = 'DtMtAS_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sNameF, sMillingAs) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMillingAs + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nId1, -1}}) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + else + local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + end + -- recupero la lavorazione, se antischeggia già inserita prendo quella + local sMilling = EgtIf( sMillingAs, sMillingAs, ML.FindMilling( 'DtMortise')) if not sMilling then local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) EgtOutLog( sErr) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 560d7f7..2fa3557 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2019/12/07 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo profilo libero per Travi -- Tabella per definizione modulo @@ -33,17 +33,11 @@ function ProcessFreeContour.IsHeadFeature( Proc, b3Raw, dCurrOvmH) -- se pocket, ne verifico la direzione di lavorazione local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) if bPocket then - local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 - if not AuxId then - return false - end + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return false end AuxId = AuxId + Proc.Id local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - if vtN:getX() < 0.5 then - return false - else - return true - end + return ( vtN:getX() >= 0.5) end -- deve occupare la maggior parte dell'area if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then @@ -67,17 +61,11 @@ function ProcessFreeContour.IsTailFeature( Proc, b3Raw) -- se pocket, ne verifico la direzione di lavorazione local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) if bPocket then - local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 - if not AuxId then - return false - end + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return false end AuxId = AuxId + Proc.Id local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - if vtN:getX() > - 0.5 then - return false - else - return true - end + return ( vtN:getX() <= - 0.5) end -- deve occupare la maggior parte dell'area if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then @@ -89,22 +77,21 @@ end --------------------------------------------------------------------- -- Classificazione della feature -function ProcessFreeContour.Classify( Proc) +function ProcessFreeContour.Classify( Proc, b3Raw) -- verifico se di tipo pocket local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) - -- se non è pocket, è indifferente alla posizione - if not bPocket then - return true, false - end - -- è pocket, devo verificare la normale del piano di svuotatura (versore estrusione del contorno) - local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 - if not AuxId then - return false - end + -- recupero la curva associata + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return false end AuxId = AuxId + Proc.Id local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - -- verifico se la feature è lavorabile solo da sotto (tasca con normale verso il basso) - local bDown = ( vtN:getZ() < - 0.1) + -- verifico se va lavorata da sotto + local bDown = false + if not bPocket then + bDown = ( vtN:getZ() < - 0.5) and Proc.Box:getDimZ() < 0.9 * b3Raw:getDimZ() + else + bDown = ( vtN:getZ() < - 0.5) + end return true, bDown end diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index 32f5830..a12393d 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -1,4 +1,4 @@ --- ProcessProfConcave.lua by Egaltech s.r.l. 2020/03/04 +-- ProcessProfConcave.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -398,7 +398,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then @@ -457,7 +457,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index fc9390b..f8991d1 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -1,4 +1,4 @@ --- ProcessProfConvex.lua by Egaltech s.r.l. 2020/03/04 +-- ProcessProfConvex.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -398,7 +398,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then @@ -457,7 +457,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then diff --git a/LuaLibs/ProcessProfHead.lua b/LuaLibs/ProcessProfHead.lua index ca10bf9..9a6a426 100644 --- a/LuaLibs/ProcessProfHead.lua +++ b/LuaLibs/ProcessProfHead.lua @@ -1,4 +1,4 @@ --- ProcessProfHead.lua by Egaltech s.r.l. 2020/03/04 +-- ProcessProfHead.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -395,7 +395,7 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then @@ -454,7 +454,7 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco -- e uscita - ModifySideAndInvertAndLead( Proc, bHead, dToolDiam) + ModifySideAndInvertAndLead( Proc, bHead, dToolDiam, true) end -- se abilitata, aggiungo lavorazione di finitura if bFinish then diff --git a/LuaLibs/ProcessStepJointNotch.lua b/LuaLibs/ProcessStepJointNotch.lua index dfaa151..d177ed6 100644 --- a/LuaLibs/ProcessStepJointNotch.lua +++ b/LuaLibs/ProcessStepJointNotch.lua @@ -1,4 +1,4 @@ --- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/03/17 +-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/03/18 -- Gestione calcolo tacca a gradino per Travi -- Tabella per definizione modulo @@ -117,7 +117,6 @@ local function MachineByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Solid, return bOk, sErr end end - return true end @@ -133,6 +132,7 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF dElev = dLedOut end local dCollSic = 2 * BD.COLL_SIC + local sTuuidMstr -- calcolo il diametro utensile local dDiamTool if nUseRoughTool == 1 then @@ -147,6 +147,13 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF EgtOutLog( sErr) return false, sErr end + -- recupero il diametro dell'utensile + if EgtMdbSetCurrMachining( sPocketing) then + sTuuidMstr = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuidMstr) or '') then + dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dDiamTool + end + end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. 'F' .. tostring( nFaceRef - 1) local nMchFId = EgtAddMachining( sName, sPocketing) @@ -165,10 +172,8 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF else EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) end - -- se tasca aperta e non lavorata col truciolatore, imposto opportuno attacco - if sMchFind == 'OpenPocket' and nUseRoughTool == 0 then - EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) - end + -- La tasca ha sempre almeno un lato aperto, imposto opportuno attacco + EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) -- imposto elevazione local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) @@ -181,24 +186,25 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF return false, sErr end end - return true + return true, '', sTuuidMstr end --------------------------------------------------------------------- local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBigInd, nSmaInd, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng) local sMchFind = 'Pocket' - -- se feature non larga come trave provo a verificare se sborda da un lato o è completamente dentro la faccia del trave - if nDiffWidth ~= 1 then sMchFind = 'OpenPocket' end - -- se feature non passante disabilito eventuale sgrossatore - if nDiffWidth ~= 0 then nUseRoughTool = 0 end - + -- se feature é larga come trave imposto openpocket + if nDiffWidth == 0 then + sMchFind = 'OpenPocket' + -- altrimenti se non è passante disabilito il truciolatore + else + nUseRoughTool = 0 + end -- applico la svuotatura - local bOk, sErr = MakePocket( Proc, nPartId, ptPs, vtN, nBigInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx) + local bOk, sErr, sTuuidMstr = MakePocket( Proc, nPartId, ptPs, vtN, nBigInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx) if not bOk then return bOk, sErr end - -- se angolo tra le facce maggiore di 90, inserisco la contornatura o svuotatura del lato più corto if ( 180 + dAng) > 90.1 then -- se la normale della faccia corta si discosta dalla trave di più di 30 gradi utilizzo la svutatura altrimenti la contornatura @@ -234,7 +240,13 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, end end end - local sMilling = ML.FindMilling( 'LongSmallCut') + local sMilling + if nUseRoughTool > 0 then + sMilling = ML.FindMilling( 'Long2Cut', nil, sTuuidMstr) + else + sMilling = ML.FindMilling( 'LongSmallCut', nil, sTuuidMstr) + end + if not sMilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' EgtOutLog( sErr) @@ -262,6 +274,8 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, EgtSetMachiningGeometry( {{ Proc.Id, (nSmaInd-1)}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- setto inversione del percorso + EgtSetMachiningParam( MCH_MP.INVERT, true) -- applico gli allungamenti o accorciamenti considerando che la lavorazione è invertita EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, dTDiam / 2, - dTDiam / 2)) EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, dTDiam / 2, - dTDiam / 2)) @@ -339,7 +353,6 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth return bOk, sErr end end - return true end