From ca0630ad2a9471444fb98dbb401e2207e603574d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 30 Jul 2019 11:33:45 +0000 Subject: [PATCH] DataBeam : - migliorie e correzioni. --- LuaLibs/BeamLib.lua | 2 +- LuaLibs/ProcessDrill.lua | 9 ++++-- LuaLibs/ProcessLapJoint.lua | 64 +++++++++++++++++++++++++++++-------- Process.lua | 4 +-- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 879968e..2048c43 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -674,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) and vtN:getZ() < 0.95 then + if ( vtV1:getZ() > -0.1 or vtV2:getZ() > -0.1) and ( abs( vtV1:getY()) > 0.707 or abs( vtV2:getY()) > 0.707 or 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/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index bc8725b..8bb00b3 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2019/07/24 +-- ProcessDrill.lua by Egaltech s.r.l. 2019/07/29 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -142,9 +142,14 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- recupero i dati dell'utensile local dMaxDepth = 20 if EgtMdbSetCurrMachining( sDrilling) then + local bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING) local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + if bIsDrilling then + dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth + else + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end end end -- se foro intermedio e inclinato, limito il massimo affondamento diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6faf55b..8ff9b5b 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/26 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/30 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -112,7 +112,8 @@ 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)) or Proc.Box:getDimY() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM + local bSmall = ( ( Proc.Head or Proc.Tail) and Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) or + ( not ( Proc.Head or Proc.Tail) and 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)) @@ -297,9 +298,8 @@ local function MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw) return false, sErr end -- aggiungo sgrossatura e la lavoro - local AddId = EgtSurfTmConvexHullInBBox( EgtGetParent( Proc.Id), Proc.Id, b3Raw, GDB_RT.GLOB) + local AddId = EgtSurfTmConvexHullInBBox( nAddGrpId, Proc.Id, b3Raw, GDB_RT.GLOB) if AddId then - EgtRelocate( AddId, nAddGrpId) EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg} @@ -532,31 +532,67 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) end -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente + local sWarn if dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dFacElev) dFacElev = dMaxDepth - local sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth' + sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth' EgtOutLog( sWarn) end - -- imposto elevazione - EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';') - -- dichiaro non si generano sfridi per VMill - EgtSetMachiningParam( MCH_MP.USERNOTES, 'VMRS=0;') + -- imposto elevazione e dichiaro non si generano sfridi per VMill + local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';' + sNotes = sNotes .. 'VMRS=0;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end - return true + return true, sWarn end --------------------------------------------------------------------- local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) - -- troppo lunga, per il momento la salto, andrà spezzata in parti - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' feature too long' - EgtOutLog( sErr) - return false, sErr + -- 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 + -- recupero l'ingombro del grezzo di appartenenza + local b3Raw = EgtGetRawPartBBox( nRawId) + -- la divido in parti lungo X + local vAddId = {} + local nPart = ceil( Proc.Box:getDimX() / min( BD.LONGCUT_MAXLEN, 0.5 * b3Raw:getDimX())) + local dPartLen = Proc.Box:getDimX() / nPart + local Xmin = Proc.Box:getMin():getX() + for i = 1, nPart do + -- eseguo divisione + local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) or GDB_ID.NULL + EgtSetName( AddId, 'AddPart_' .. tostring( Proc.Id) .. '_' .. tostring( i)) + if i > 1 then + local ptOn = Point3d( Xmin + ( i - 1) * dPartLen, 0, 0) + EgtCutSurfTmPlane( AddId, ptOn, -X_AX(), true, GDB_RT.GLOB) + end + if i < nPart then + local ptOn = Point3d( Xmin + i * dPartLen, 0, 0) + EgtCutSurfTmPlane( AddId, ptOn, X_AX(), true, GDB_RT.GLOB) + end + table.insert( vAddId, AddId) + end + -- applico le lavorazioni sulle diverse parti + 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, sErr = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId) + if not bOk then + return bOk, sErr + end + end + return true end --------------------------------------------------------------------- diff --git a/Process.lua b/Process.lua index 7d48425..1cd3315 100644 --- a/Process.lua +++ b/Process.lua @@ -208,10 +208,10 @@ local function MyProcessFeatures() for i = 1, #Stats do if 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, Stats[i].Msg) 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, Stats[i].Msg) end end if #sOutput > 0 then EgtOutLog( sOutput) end