From 3f191506812a53a5f450ff360e71cad344fb405a Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 12 Feb 2020 19:49:48 +0000 Subject: [PATCH] DataBeam : - migliorato calcolo ingombri di testa delle feature per posizionamento pinze - feature Chamfer divisa in parti se lunga. --- BatchProcess.lua | 10 ++- LuaLibs/BeamLib.lua | 7 ++- LuaLibs/FacesBySaw.lua | 8 ++- LuaLibs/ProcessChamfer.lua | 117 ++++++++++++++++++++++++++---------- LuaLibs/ProcessLapJoint.lua | 56 ++++++++++++++++- 5 files changed, 157 insertions(+), 41 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index 767fb0a..0a6b6a6 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2020/01/30 +-- BatchProcess.lua by Egaltech s.r.l. 2020/02/12 -- 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. @@ -14,6 +14,7 @@ -- 2020/01/08 Aggiunta seconda sezione limite (BD.MAX_WIDTH2 x BD.MAX_HEIGHT2). -- 2020/01/14 Si carica ultimo gruppo di lavoro. Corretto problema con nome non definito in segnalazione errore in generazione o stima. -- 2020/01/30 File Diff con nome del btl. +-- 2020/02/12 Migliorie nella gestione degli errori. -- Intestazioni require( 'EgtBase') @@ -421,7 +422,10 @@ end if ( BEAM.FLAG == 3 or BEAM.FLAG == 4) and bVerifyCollision then local bSimOk, nErr, sErr = EgtSimulate() if not bSimOk then - if nErr == MCH_SHE.COLLISION then + if nErr == MCH_SHE.INIT then + BEAM.ERR = 19 + BEAM.MSG = 'Error in clamps disposition' + elseif nErr == MCH_SHE.COLLISION then BEAM.ERR = 22 BEAM.MSG = 'Head-part collision' elseif nErr == MCH_SHE.OUTSTROKE then @@ -429,7 +433,7 @@ if ( BEAM.FLAG == 3 or BEAM.FLAG == 4) and bVerifyCollision then BEAM.MSG = 'Axis outstroke ' .. sErr elseif nErr == MCH_SHE.SPECIAL then BEAM.ERR = 24 - BEAM.MSG = 'Charriot error ' .. sErr + BEAM.MSG = 'Clamp move error ' .. sErr else BEAM.ERR = 25 BEAM.MSG = 'General failure (contact supplier)' diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 37d72d6..431a7cd 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2020/02/06 +-- BeamLib.lua by Egaltech s.r.l. 2020/02/12 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -740,8 +740,11 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, Par5, dV end ------------------------------------------------------------------------------------------------------------- -function BeamLib.UpdateHCING( nRawId, dHCI) +function BeamLib.UpdateHCING( nRawId, dHCI, dDist) local dOldHCI = EgtGetInfo( nRawId, 'HCING', 'd') + if dDist and dDist > dOldHCI + 10 then + return + end if not dOldHCI or dHCI > dOldHCI then EgtSetInfo( nRawId, 'HCING', dHCI) end diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 1d48a97..c19efbf 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -1,4 +1,4 @@ --- FacesBySaw.lua by Egaltech s.r.l. 2019/09/20 +-- FacesBySaw.lua by Egaltech s.r.l. 2020/02/12 -- Gestione taglio con lama di feature con una, due o tre facce -- Tabella per definizione modulo @@ -134,11 +134,15 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName) local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then if Proc.Head then - local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() BL.UpdateHCING( nRawId, dOffs) elseif Proc.Tail then local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() BL.UpdateTCING( nRawId, dOffs) + elseif Proc.Box:getCenter():getX() > b3Solid:getCenter():getX() then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + local dDist = b3Solid:getMax():getX() - Proc.Box:getMax():getX() + BL.UpdateHCING( nRawId, dOffs, dDist) end end return true diff --git a/LuaLibs/ProcessChamfer.lua b/LuaLibs/ProcessChamfer.lua index 06e76e4..0175aa4 100644 --- a/LuaLibs/ProcessChamfer.lua +++ b/LuaLibs/ProcessChamfer.lua @@ -1,4 +1,4 @@ --- ProcessChamfer.lua by Egaltech s.r.l. 2020/02/11 +-- ProcessChamfer.lua by Egaltech s.r.l. 2020/02/12 -- Gestione calcolo profilo libero per Travi -- Tabella per definizione modulo @@ -33,14 +33,6 @@ function ProcessChamfer.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- inserisco la lavorazione - local sName = 'Chm_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchId = EgtAddMachining( sName, sMilling) - if not nMchId then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end -- recupero i dati dell'utensile local dMillDiam = 10 local dMaxMat = 20 @@ -51,8 +43,17 @@ function ProcessChamfer.Make( Proc, nPhase, nRawId, nPartId) dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat end end + -- se onde if AuxId then + -- inserisco la lavorazione + local sName = 'Chm_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, sMilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end -- impongo lavorazione dall'alto local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) if vtExtr:getZ() < 0 then @@ -73,11 +74,19 @@ function ProcessChamfer.Make( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + -- altrimenti smusso standard else -- normale ed elevazione della faccia principale local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) local _, dElev = BL.GetPointDirDepth( nPartId, ptC, vtN) + local bFront = ( vtN:getY() < 0) -- limitazioni su inizio e fine derivanti da altre facce local bLimXmin = false local bLimXmax = false @@ -108,31 +117,73 @@ function ProcessChamfer.Make( Proc, nPhase, nRawId, nPartId) if bLimXmax then dEndAll = dAllExtr end if bLimXmin then dStartAll = dAllExtr end end - -- lavoro tenendo l'utensile a sinistra - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- imposto lavorazione un poco sotto - local sDepth = 'TH+'..EgtNumToString( BD.CUT_EXTRA) - EgtSetMachiningParam( MCH_MP.DEPTH_STR, sDepth) - EgtSetMachiningParam( MCH_MP.STEP, 0) - -- imposto utilizzo faccia - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) - -- imposto attacchi e uscite - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAll) - EgtSetMachiningParam( MCH_MP.LIPERP, dMillDiam / 4) - EgtSetMachiningParam( MCH_MP.LITANG, 0) - EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAll) - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, 0}}) - end - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr + -- determino numero di parti + local dLen = Proc.Box:getDimX() + local dStartAccDist = BD.LONGCUT_ENDLEN + local dEndAccDist = BD.LONGCUT_ENDLEN + local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN) + local dC = 0 + if nC > 0 then + dC = dLen / ( nC + 2) + dStartAccDist = dC + dEndAccDist = dC + nC = nC + 2 + else + if dLen > min( dStartAccDist, dEndAccDist) then + nC = 2 + dStartAccDist = dLen/2 + dEndAccDist = dStartAccDist + else + nC = 1 + dStartAccDist = 0 + dEndAccDist = 0 + end + end + -- eseguo le diverse parti + for i = 1, nC do + -- inserisco la lavorazione + local sName = 'Chm_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, sMilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- lavoro tenendo l'utensile a sinistra + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- imposto lavorazione un poco sotto + local sDepth = 'TH+'..EgtNumToString( BD.CUT_EXTRA) + EgtSetMachiningParam( MCH_MP.DEPTH_STR, sDepth) + EgtSetMachiningParam( MCH_MP.STEP, 0) + -- imposto utilizzo faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- imposto attacchi e uscite + local dSal, dEal + if bFront then + dSal = EgtIf( i == 1, dStartAll, -( i - 1) * dC) + dEal = EgtIf( i == nC, dEndAll, -( nC - i) * dC) + else + dSal = EgtIf( i == nC, dStartAll, -( nC - i) * dC) + dEal = EgtIf( i == 1, dEndAll, -( i - 1) * dC) + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + EgtSetMachiningParam( MCH_MP.LIPERP, dMillDiam / 4) + EgtSetMachiningParam( MCH_MP.LITANG, 0) + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, 0}}) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end end + return true end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index d1f4d75..186e7b5 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/02/10 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/02/12 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -139,6 +139,13 @@ end --------------------------------------------------------------------- -- Verifica se feature di testa function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) + -- se una sola faccia + if Proc.Fct == 1 then + local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + if vtN0:getX() > 0 then + return true + end + end -- verifico se è in testa if Proc.Box:getMax():getX() < b3Raw:getMax():getX() - dCurrOvmH - BD.MAX_DIST_HTFEA then return false @@ -175,6 +182,13 @@ end --------------------------------------------------------------------- -- Verifica se feature di coda function ProcessLapJoint.IsTailFeature( Proc, b3Raw) + -- se una sola faccia + if Proc.Fct == 1 then + local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + if vtN0:getX() < 0 then + return true + end + end -- se può essere fatto con utensile tipo lama local bUseBHSideMill, bHead = VerifyIfByBHSideMill( Proc) if bUseBHSideMill then @@ -273,6 +287,13 @@ end local function MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) + -- recupero l'ingombro della trave + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end -- verifico il numero di facce della tacca assert( ( Proc.Fct == 1), 'Error : MakeOneFaceByMill in LapJoint with ' .. tostring( Proc.Fct) .. ' faces') -- dati della faccia @@ -321,6 +342,17 @@ local function MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- eventuale segnalazione ingombro di testa o coda + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) + if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + if Proc.Head then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( nRawId, dOffs) + elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + BL.UpdateTCING( nRawId, dOffs) + end + end return true end @@ -328,6 +360,13 @@ end local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) + -- recupero l'ingombro della trave + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end -- verifico il numero di facce della tacca assert( ( Proc.Fct == 2), 'Error : MakeTwoFacesByMill in LapJoint with ' .. tostring( Proc.Fct) .. ' faces') -- dati delle facce @@ -418,6 +457,21 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- eventuale segnalazione ingombro di testa o coda + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) + if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + if Proc.Head then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( nRawId, dOffs) + elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + BL.UpdateTCING( nRawId, dOffs) + elseif Proc.Box:getCenter():getX() > b3Solid:getCenter():getX() then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + local dDist = b3Solid:getMax():getX() - Proc.Box:getMax():getX() + BL.UpdateHCING( nRawId, dOffs, dDist) + end + end return true end