From 8dee1a0c97255f667c748d6f0d24c94c6fcf0a89 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 29 Jul 2019 15:01:19 +0000 Subject: [PATCH] DataBeam : - correzioni e migliorie varie. --- BatchProcess.lua | 47 ++++-- LuaLibs/BeamExec.lua | 21 ++- LuaLibs/BeamLib.lua | 23 ++- LuaLibs/MachiningLib.lua | 8 +- LuaLibs/ProcessDoubleCut.lua | 4 +- LuaLibs/ProcessDrill.lua | 2 +- LuaLibs/ProcessFreeContour.lua | 32 +++- LuaLibs/ProcessLapJoint.lua | 62 ++++--- LuaLibs/ProcessLongCut.lua | 269 ++++++++++++++++++++----------- LuaLibs/ProcessLongDoubleCut.lua | 10 +- LuaLibs/ProcessMortise.lua | 4 +- LuaLibs/ProcessTenon.lua | 2 +- 12 files changed, 325 insertions(+), 159 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index 937728e..1242953 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2019/07/24 +-- BatchProcess.lua by Egaltech s.r.l. 2019/07/25 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. @@ -10,6 +10,12 @@ require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) +-- Per test +--BEAM = {} +--BEAM.FILE = 'c:\\TechnoEssetre7\\EgtBtl\\Part_15_116.btl' +--BEAM.MACHINE = 'FAST' +--BEAM.FLAG = 3 + -- Flag abilitazione controllo collisione local bVerifyCollision = true @@ -42,7 +48,7 @@ local function PostErrView( nErr, sMsg) if nErr ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then EgtSetView( SCE_VD.ISO_SW, false) EgtZoom( SCE_ZM.ALL) - EgtOutBox( sMsg .. ' (error ' .. tostring( nErr) .. ')', 'BatchProcess', 'ERRORS') + EgtOutBox( sMsg, 'BatchProcess (err=' .. tostring( nErr) .. ')', 'ERRORS') end end @@ -51,7 +57,7 @@ local function PostWarnView( nWarn, sMsg) if nWarn ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then EgtSetView( SCE_VD.ISO_SW, false) EgtZoom( SCE_ZM.ALL) - EgtOutBox( sMsg .. ' (warning ' .. tostring( nWarn) .. ')', 'BatchProcess', 'WARNINGS') + EgtOutBox( sMsg, 'BatchProcess (wrn=' .. tostring( nErr) .. ')', 'WARNINGS') end end @@ -236,8 +242,10 @@ local nErrCnt = 0 local nWarnCnt = 0 local sOutput = '' for i = 1, #Stats do + local sMsg = Stats[i].Msg + sMsg = string.gsub( sMsg, '\n', ' ', 10) + sMsg = string.gsub( sMsg, '\r', ' ', 10) if Stats[i].Err == 0 then - sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d Ok\n', Stats[i].CutId, Stats[i].TaskId) BEAM.ERR = 0 BEAM.MSG = '---' BEAM.ROT = Stats[i].Rot or 0 @@ -246,24 +254,30 @@ for i = 1, #Stats do WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) elseif Stats[i].Err > 0 then nErrCnt = nErrCnt + 1 - sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, sMsg) BEAM.ERR = 19 - BEAM.MSG = Stats[i].Msg + BEAM.MSG = sMsg BEAM.ROT = Stats[i].Rot or 0 BEAM.CUTID = Stats[i].CutId BEAM.TASKID = Stats[i].TaskId WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) elseif Stats[i].Err < 0 then nWarnCnt = nWarnCnt + 1 - sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, sMsg) BEAM.ERR = -19 - BEAM.MSG = Stats[i].Msg + BEAM.MSG = sMsg BEAM.ROT = Stats[i].Rot or 0 BEAM.CUTID = Stats[i].CutId BEAM.TASKID = Stats[i].TaskId WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) end end + +-- Salvo il progetto +local sNgeFile = EgtChangePathExtension( BEAM.FILE, '.nge') +EgtSaveFile( sNgeFile) + +-- Visualizzazione avvisi o errori if #sOutput > 0 then EgtOutLog( sOutput) end if nErrCnt > 0 then PostErrView( 19, sOutput) @@ -272,10 +286,6 @@ elseif nWarnCnt > 0 then PostWarnView( 19, sOutput) end --- Salvo il progetto -local sNgeFile = EgtChangePathExtension( BEAM.FILE, '.nge') -EgtSaveFile( sNgeFile) - -- Genero programma CN, se richiesto if BEAM.FLAG == 0 then if not EgtGenerate( '', 'EgtCAM5 - ' .. sNgeFile) then @@ -303,12 +313,17 @@ EgtOutLog( sTime) if BEAM.FLAG == 3 and bVerifyCollision then local bSimOk, nErr, sErr = EgtSimulate() if not bSimOk then - BEAM.ERR = 22 - if nErr == MCH_SHE.OUTSTROKE then - BEAM.MSG = 'Axis outstroke ' .. sErr - elseif nErr == MCH_SHE.COLLISION then + if nErr == MCH_SHE.COLLISION then + BEAM.ERR = 22 BEAM.MSG = 'Head-part collision' + elseif nErr == MCH_SHE.OUTSTROKE then + BEAM.ERR = 23 + BEAM.MSG = 'Axis outstroke ' .. sErr + elseif nErr == MCH_SHE.SPECIAL then + BEAM.ERR = 24 + BEAM.MSG = 'Charriot error ' .. sErr else + BEAM.ERR = 25 BEAM.MSG = 'General failure (contact supplier)' end BEAM.ROT = 0 diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index dfc57c9..2bcffca 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -368,7 +368,7 @@ local function OrderFeatures( vProc, b3Raw) return B1.Box:getMax():getX() + 100 > B2.Box:getCenter():getX() end -- se sono fori e hanno posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs) - if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 400 then + if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 600 then if abs( B1.Diam - B2.Diam) < 1.0 then if B1.Fcs == B2.Fcs then return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() @@ -388,7 +388,7 @@ local function OrderFeatures( vProc, b3Raw) if B1.Head ~= B2.Head then return B1.Head end - -- confronto standard per feature che non si sovrappongono in X + -- confronto standard if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 0.5 * ( B1.Box:getDimX() + B2.Box:getDimX()) then return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 0.5 * ( B1.Box:getDimY() + B2.Box:getDimY()) then @@ -415,6 +415,23 @@ local function OrderFeatures( vProc, b3Raw) end end end + -- riunisco marcature, testi e decori non troppo lontani + for i = 1, #vProc do + local ProcI = vProc[i] + if ProcI.Prc == 60 or ProcI.Prc == 61 or ProcI.Prc == 959 then + for j = i + 1, #vProc do + local ProcJ = vProc[j] + if ( ProcJ.Prc == 60 or ProcJ.Prc == 61 or ProcJ.Prc == 959) and + ProcJ.Head == ProcI.Head and ProcJ.Tail == ProcI.Tail and + abs( ProcJ.Box:getCenter():getX() - ProcI.Box:getCenter():getX()) < 300.0 then + if j > i + 1 then + table.insert( vProc, i + 1, table.remove( vProc, j)) + end + break + end + end + end + end end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 49032f4..879968e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2019/07/24 +-- BeamLib.lua by Egaltech s.r.l. 2019/07/25 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -355,6 +355,12 @@ function BeamLib.GetFaceWithMostAdj( nSurfId) end vUcut[i] = bUcut end + -- se 4 facce tutte con adiacenza 2, allora è un tunnel + if nFacCnt == 4 then + if vAdj[1] == 2 and vAdj[2] == 2 and vAdj[3] == 2 and vAdj[4] == 2 then + return -1, GEO.INFINITO + end + end -- recupero le facce non in sottosquadra e con il maggior numero di adiacenze local nFacInd = {} local nMaxAdj = 0 @@ -370,18 +376,25 @@ function BeamLib.GetFaceWithMostAdj( nSurfId) end end -- premio la faccia con minore elevazione - local nFacOpt - local dMinElev = GEO.INFINITO + local nFacOpt, nFacOpt2 + local dMinElev, dMinElev2 = GEO.INFINITO, GEO.INFINITO for i = 1, #nFacInd do local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacInd[i], GDB_ID.ROOT) local frOCS = Frame3d( ptC, vtN) ; local b3Box = EgtGetBBoxRef( nSurfId, GDB_BB.STANDARD, frOCS) if b3Box:getDimZ() < dMinElev then + if dMinElev < dMinElev2 then + nFacOpt2 = nFacOpt + dMinElev2 = dMinElev + end nFacOpt = nFacInd[i] dMinElev = b3Box:getDimZ() + elseif b3Box:getDimZ() < dMinElev2 then + nFacOpt2 = nFacInd[i] + dMinElev2 = b3Box:getDimZ() end end - return nFacOpt, dMinElev + return nFacOpt, dMinElev, nFacOpt2, dMinElev2 end --------------------------------------------------------------------- @@ -661,7 +674,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, nOrthoOp local b3Box = BBox3d( b3Raw) b3Box:expand( dCutSic) local dLiTang, dLiPerp, dLoTang, dLoPerp - if ( vtV1:getZ() > -0.1 or vtV2:getZ() > -0.1) then + if ( vtV1:getZ() > -0.1 or vtV2:getZ() > -0.1) and vtN:getZ() < 0.95 then dLiTang, dLiPerp, dLoTang, dLoPerp = BeamLib.CalcLeadInOutGeom( ptP1, ptP2, vtV1, vtV2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) else dLiTang, dLiPerp, dLoTang, dLoPerp = BeamLib.CalcLeadInOutTangGeom( ptP1, ptP2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index f27023c..b9f50a4 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1,4 +1,4 @@ --- MachiningLib.lua by Egaltech s.r.l. 2019/07/16 +-- MachiningLib.lua by Egaltech s.r.l. 2019/07/25 -- Libreria ricerca lavorazioni per Travi -- Tabella per definizione modulo @@ -38,15 +38,17 @@ function MachiningLib.FindMilling( sType) end --------------------------------------------------------------------- -function MachiningLib.FindPocketing( sType, dMaxMat) +function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth) for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.On and Pocketing.Type == sType and EgtMdbSetCurrMachining( Pocketing.Name) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) local sTool = EgtTdbGetToolFromUUID( sTuuid) if sTool and EgtTdbSetCurrTool( sTool) then + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - if not dMaxMat or dMaxMat < dTMaxDepth then + if ( not dMaxDiam or dTDiam < dMaxDiam) and + ( not dDepth or dTMaxDepth > dDepth) then return Pocketing.Name end end diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index d01f6ef..8254c0b 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2019/03/29 +-- ProcessDrill.lua by Egaltech s.r.l. 2019/07/25 -- Gestione calcolo doppi tagli di lama per Travi -- Tabella per definizione modulo @@ -221,10 +221,10 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end BL.UpdateHCING( nRawId, dOffs) elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Raw:getMin():getX() if vtNm:getZ() > 0.5 then dOffs = 0.5 * dOffs end - local dOffs = Proc.Box:getMax():getX() - b3Raw:getMin():getX() BL.UpdateTCING( nRawId, dOffs) end return true diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 505458b..bc8725b 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -100,7 +100,7 @@ function ProcessDrill.Classify( Proc, b3Raw) return false, false end local bOpen = ( Proc.Fce ~= 0) - local bFaceDown = ( ptCen:getZ() < b3Raw:getMin():getZ() + dDiam) + local bFaceDown = ( ptCen:getZ() < b3Raw:getMin():getZ() + dDiam) and vtExtr:getZ() < -0.5 -- verifico se il foro è fattibile solo da sotto local bDown = (( vtExtr:getZ() < BD.DRILL_VZ_MIN or bFaceDown) and ( not bOpen or Proc.Flg ~= 1)) return true, bDown diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index a8975ae..7172f0f 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -30,6 +30,21 @@ function ProcessFreeContour.IsHeadFeature( Proc, b3Raw, dCurrOvmH) if Proc.Box:getDimX() > 0.5 * b3Raw:getDimX() then return false end + -- 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 + AuxId = AuxId + Proc.Id + local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + if vtN:getX() < 0.5 then + return false + else + return true + end + 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 return true @@ -49,6 +64,21 @@ function ProcessFreeContour.IsTailFeature( Proc, b3Raw) if Proc.Box:getDimX() > 0.5 * b3Raw:getDimX() then return false end + -- 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 + AuxId = AuxId + Proc.Id + local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + if vtN:getX() > - 0.5 then + return false + else + return true + end + 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 return true @@ -233,7 +263,7 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) --local bToolInv = ( vtExtr:getZ() < -0.1) -- recupero la lavorazione - local sPocketing = ML.FindPocketing( 'Pocket', dDepth) + local sPocketing = ML.FindPocketing( 'Pocket', nil, dDepth) if not sPocketing then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' EgtOutLog( sErr) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index c2acdc5..6faf55b 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/12 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/26 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -46,8 +46,12 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) return true end -- deve avere la normale principale diretta verso la testa - local nFacInd = BL.GetFaceWithMostAdj( Proc.Id) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + if vtN:getZ() < BD.NZ_MINA and nFacInd2 then + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + nFacInd, nFacInd2 = nFacInd2, nFacInd + end if vtN:getX() < 0.5 then return false elseif Proc.Fct >= 5 then @@ -77,19 +81,17 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) return true end -- deve avere la normale principale diretta verso la coda - local nFacInd = BL.GetFaceWithMostAdj( Proc.Id) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + if vtN:getZ() < BD.NZ_MINA and nFacInd2 then + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + nFacInd, nFacInd2 = nFacInd2, nFacInd + end if vtN:getX() > -0.5 then return false - elseif Proc.Fct >= 5 then + else return true 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 - return true - end - -- non è di coda - return false end --------------------------------------------------------------------- @@ -110,19 +112,29 @@ function ProcessLapJoint.Classify( Proc) ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) -- verifico se è lavorabile solo dal basso - local bSmall = (Proc.Head or Proc.Tail) and ( Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) + local bSmall = ( (Proc.Head or Proc.Tail) and ( Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM)) or Proc.Box:getDimY() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or ( vtN[1]:getZ() < BD.NZ_MINA and ( vtN[2]:getZ() < -0.1 or not bSmall)) or ( vtN[2]:getZ() < BD.NZ_MINA and ( vtN[1]:getZ() < -0.1 or not bSmall)) return true, bDown -- se più di 2 facce else - -- recupero la faccia con il maggior numero di adiacenze più grande - local nFacInd = BL.GetFaceWithMostAdj( Proc.Id) + -- recupero la faccia con il maggior numero di adiacenze e minor elevazione + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) + if nFacInd < 0 then + return false + end -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) -- verifico se è lavorabile solo dal basso local bDown = ( vtN:getZ() < BD.NZ_MINA) + -- se verso il basso, verifico se utilizzabile seconda faccia + if bDown then + if nFacInd2 then + local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + bDown = ( vtN2:getZ() < BD.NZ_MINA) + end + end return true, bDown end end @@ -463,13 +475,18 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) -- recupero il numero di facce della tacca assert( ( Proc.Fct > 2), 'Error : MakeMoreFaces in LapJoint with ' .. tostring( Proc.Fct) .. ' faces') -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev = BL.GetFaceWithMostAdj( Proc.Id) + local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id) assert( nFacInd, 'Error : MakeMoreFaces could not find reference face') -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + -- se orientata verso il basso, verifico l'alternativa + if vtN:getZ() < BD.NZ_MINA and nFacInd2 then + ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + nFacInd, nFacInd2 = nFacInd2, nFacInd + end local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- verifico non sia orientata verso il basso - local bFaceOk = ( vtN:getZ() >= BD.NZ_MINB) + local bFaceOk = ( vtN:getZ() >= BD.NZ_MINA) if not bFaceOk then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' LapJoint from bottom impossible' EgtOutLog( sErr) @@ -483,26 +500,19 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end end -- recupero la lavorazione - local sPocketing = ML.FindPocketing( 'Mortise') + local sPocketing = ML.FindPocketing( 'Mortise', min( dH, dV)) + -- se non trova una svuotatura adatta, provo con la sega a catena o lama if not sPocketing then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' - EgtOutLog( sErr) - return false, sErr + return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) end -- recupero i dati dell'utensile - local dMillDiam = 20 local dMaxDepth = 0 if EgtMdbSetCurrMachining( sPocketing) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - BD.COLL_SIC + dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) end end - -- se una dimensione della faccia è più piccola del diametro utensile, va usata la sega a catena o la lama - if dH < dMillDiam or dV < dMillDiam then - return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) - end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sPocketing) diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index e242e8d..253f8ea 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/22 +-- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/25 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -6,6 +6,7 @@ local ProcessLongCut = {} -- Include require( 'EgtBase') +local BL = require( 'BeamLib') EgtOutLog( ' ProcessLongCut started', 1) @@ -22,13 +23,14 @@ end --------------------------------------------------------------------- -- Classificazione della feature function ProcessLongCut.Classify( Proc) - -- verifico le normali delle facce - local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) - for i = 1, nFacetCnt do - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) - if vtN:getZ() < - 0.707 then - return true, true - end + -- se una sola faccia non ci sono limiti + if Proc.Fct == 1 then + return true, false + end + -- verifico la normale della faccia principale + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT) + if vtN:getZ() < - 0.5 then + return true, true end return true, false end @@ -54,58 +56,164 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) bLimXmax = true end end - -- verifico che il taglio longitudinale non sia orientato verso il basso - if vtN:getZ() < 0.0 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Longitudinal Cut from bottom impossible' - EgtOutLog( sErr) - return false, sErr - end - -- recupero la lavorazione - local sMilling = ML.FindMilling( 'Long2Cut') - if not sMilling then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' - EgtOutLog( sErr) - return false, sErr - end - -- recupero il diametro dell'utensile - local dToolDiam = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + -- Verifico se lavorazione da sotto + local nSide = 1 + if vtN:getZ() < - 0.5 then nSide = -1 end + + -- Se non è sotto : lavorazione Long2Cut + if nSide ~= - 1 then + -- recupero la lavorazione + local sMilling = ML.FindMilling( 'Long2Cut') + if not sMilling then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' + EgtOutLog( sErr) + return false, sErr end - end - local dStartDist = 0 - if ( bLimXmin and vtN:getY() < 0) or ( bLimXmax and vtN:getY() > 0) then - dStartDist = dToolDiam / 2 - end - local dEndDist = 0 - if ( bLimXmin and vtN:getY() > 0) or ( bLimXmax and vtN:getY()< 0) then - dEndDist = dToolDiam / 2 - end - -- determino numero di parti - local nC = ceil( ( dLen - 2 * BD.LONGCUT_ENDLEN) / BD.LONGCUT_MAXLEN) - local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC - local dAccDist = BD.LONGCUT_ENDLEN - if nC > 0 then - nC = nC + 2 - else - nC = EgtIf( dLen > BD.LONGCUT_ENDLEN, 2, 1) - dAccDist = EgtIf( nC == 2, dLen / 2, 0) - end - -- si percorre il lato basso della faccia - local nM = 0 - for i = 1, nC do - -- ciclo sulle passate - local nO = 1 - local dStep = 0 - if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then - nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam) - if nO > 1 then - dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1) + -- recupero il diametro dell'utensile + local dToolDiam = 0 + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam end end - for k = nO, 1, -1 do + local dStartDist = 0 + if ( bLimXmin and vtN:getY() < 0) or ( bLimXmax and vtN:getY() > 0) then + dStartDist = dToolDiam / 2 + end + local dEndDist = 0 + if ( bLimXmin and vtN:getY() > 0) or ( bLimXmax and vtN:getY()< 0) then + dEndDist = dToolDiam / 2 + end + -- determino numero di parti + local nC = ceil( ( dLen - 2 * BD.LONGCUT_ENDLEN) / BD.LONGCUT_MAXLEN) + local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC + local dAccDist = BD.LONGCUT_ENDLEN + if nC > 0 then + nC = nC + 2 + else + nC = EgtIf( dLen > BD.LONGCUT_ENDLEN, 2, 1) + dAccDist = EgtIf( nC == 2, dLen / 2, 0) + end + -- si percorre il lato basso della faccia + local nM = 0 + for i = 1, nC do + -- ciclo sulle passate + local nO = 1 + local dStep = 0 + if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then + nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam) + if nO > 1 then + dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1) + end + end + for k = nO, 1, -1 do + -- inserisco le parti di lavorazione + nM = nM + 1 + local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, 0}}) + -- limito opportunamente la lavorazione + local dSal = EgtIf( i == 1, -dStartDist, - dAccDist - ( i - 2) * dC) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + local dEal = EgtIf( i == nC, -dEndDist, - dAccDist - ( nC - i - 1) * dC) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- imposto offset radiale (nullo se concavo) + if k >1 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep) + else + EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA) + end + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + end + -- se ci sono le facce limitanti + for i = 1, Proc.Fct - 1 do + -- inserisco la lavorazione + local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, i}}) + -- lato di lavoro e inversione + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- attacco e uscita + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + + -- altrimenti è sotto : lavorazione Long2CutDown + else + -- recupero la lavorazione + local sMilling = ML.FindMilling( 'Long2CutDown') + if not sMilling then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dToolDiam = 0 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- larghezza faccia + local _, _, dWidth = BL.GetFaceHvRefDim( Proc.Id, 0) + -- aggiuntivo sull'affondamento + local dAgg = BD.CUT_EXTRA + -- determino il numero di parti in cui dividere la lavorazione + local dEndLen = BD.LONGCUT_ENDLEN + if dLen < 2 * dEndLen + BD.LONGCUT_MAXLEN then + dEndLen = dLen / 3 + end + local nC = ceil( ( dLen - 2 * dEndLen) / BD.LONGCUT_MAXLEN) + local dC = 0 + if nC > 0 then dC = ( dLen - 2 * dEndLen) / nC end + nC = nC + 2 + -- ciclo sulle parti + local nM = 0 + for j = 1, nC do + -- Limitazioni della lavorazione + local nPos = EgtIf( vtN:getY() < 0, j, nC - j + 1) + local dSal = EgtIf( nPos == 1, 0, - dEndLen - ( nPos - 2) * dC) + local dEal = EgtIf( nPos == nC, 0, - dEndLen - ( nC - nPos - 1) * dC) + -- Posizione braccio portatesta + local nSCC + if vtN:getY() < 0 then + nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + else + nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + end -- inserisco le parti di lavorazione nM = nM + 1 local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) @@ -118,16 +226,17 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, 0}}) -- limito opportunamente la lavorazione - local dSal = EgtIf( i == 1, -dStartDist, - dAccDist - ( i - 2) * dC) EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) - local dEal = EgtIf( i == nC, -dEndDist, - dAccDist - ( nC - i - 1) * dC) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) - -- imposto offset radiale (nullo se concavo) - if k >1 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep) - else - EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA) - end + -- imposto posizione braccio porta testa per non ingombrare agli estremi + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto uso faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- imposto lato di lavoro e inversione + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + local dDepth = min( dMaxDepth, dWidth + dAgg) + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -136,35 +245,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) end end end - -- se ci sono le facce limitanti - for i = 1, Proc.Fct - 1 do - -- inserisco la lavorazione - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) - local nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, i}}) - -- lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- uso della faccia - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) - -- attacco e uscita - EgtSetMachiningParam( MCH_MP.LIPERP, 0) - EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 0) - EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - end + return true end diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 130eac3..ce42dfa 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -63,21 +63,23 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local nSide = 0 if vtN[1]:getZ() > -10 * GEO.EPS_SMALL and vtN[2]:getZ() > -10 * GEO.EPS_SMALL then nSide = 1 - elseif vtN[1]:getZ() < 10 * GEO.EPS_SMALL and vtN[2]:getZ() < 10 * GEO.EPS_SMALL then + elseif vtN[1]:getZ() < -10 * GEO.EPS_SMALL and vtN[2]:getZ() < -10 * GEO.EPS_SMALL then nSide = -1 end -- angolo diedro per stabilire se taglio convesso local bInt, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFc[1], nFc[2], GDB_ID.ROOT) local bConvex local bOrtho + local ptM if bInt then bConvex = ( dAng >= 0) bOrtho = ( abs( dAng + 90) < 1) + ptM = ( ptP1 + ptP2) / 2 else bConvex = true bOrtho = false + ptM = ( ptC[1] + ptC[2]) / 2 end - local ptM = ( ptC[1] + ptC[2]) / 2 -- analisi del taglio local vOrd = {} local vFaceUse = {} @@ -160,8 +162,6 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) end end for k = 1, nO do - -- determino direzione di movimento - local bToLeft = ( i == 1) -- inserisco le parti di lavorazione nM = nM + 1 local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) @@ -240,8 +240,6 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local dEal = EgtIf( nPos == nC, 0, - dEndLen - ( nC - nPos - 1) * dC) -- Posizione braccio portatesta local nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - -- determino direzione di movimento - local bToLeft = ( i == 1) -- inserisco le parti di lavorazione nM = nM + 1 local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 6b82eec..f5fd476 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -76,7 +76,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) local _, dCenElev = BL.GetPointDirDepth( nRawId, ptC, vtN) dMorH = max( dMorH, dCenElev or 0) -- recupero la lavorazione - local sPocketing = ML.FindPocketing( 'Mortise') + local sPocketing = ML.FindPocketing( 'Mortise', 30) if not sPocketing then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' EgtOutLog( sErr) @@ -89,7 +89,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - BD.COLL_SIC + dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) end end -- inserisco la lavorazione di svuotatura diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 3c0d22c..67ae8cd 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -119,7 +119,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - BD.COLL_SIC + dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) end end -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente