From a27566031bb5be4051d65ac2a3f45e39cccabaf0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 11 Feb 2025 18:46:10 +0100 Subject: [PATCH 1/5] - modifiche varie per gestione MultiDrill, al momento per Cabinet --- LuaLibs/WMachiningLib.lua | 26 +++++-- LuaLibs/WProcessDrill.lua | 129 ++++++++++++++++++++++++++++------- LuaLibs/WProcessLapJoint.lua | 2 +- LuaLibs/WallExec.lua | 34 ++++++++- 4 files changed, 157 insertions(+), 34 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index d5ed5c5..f8b3595 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -148,18 +148,27 @@ function WMachiningLib.FindSawing( sType) end --------------------------------------------------------------------- -function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets) +function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets, bUseMultiDrill, DrillingsToAvoid) if bOnlyPockets == nil or not bOnlyPockets then -- ricerca sulle forature, dal diametro maggiore al minore for i = #Drillings, 1, -1 do local Drilling = Drillings[i] - if Drilling.On and Drilling.Type == 'Drill' and SetCurrMachiningAndTool( Drilling.Name) then + if Drilling.On and EgtIf( bUseMultiDrill, Drilling.Type == 'MultiDrill', Drilling.Type == 'Drill') and SetCurrMachiningAndTool( Drilling.Name) then + local bIsToAvoid = false + if DrillingsToAvoid then + for j = 1, #DrillingsToAvoid do + if Drilling.Name == DrillingsToAvoid[j] then + bIsToAvoid = true + end + end + end local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if nMchType == MCH_MY.DRILLING and - dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL and + ( not bIsToAvoid) and + ( not dDiam or ( dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL)) and ( not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL) and (( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then return Drilling.Name, Drilling.Type, dTMaxMat @@ -171,12 +180,21 @@ function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets) for i = #Drillings, 1, -1 do local Drilling = Drillings[i] if Drilling.On and Drilling.Type == 'Pocket' and SetCurrMachiningAndTool( Drilling.Name) then + local bIsToAvoid = false + if DrillingsToAvoid then + for j = 1, #DrillingsToAvoid do + if Drilling.Name == DrillingsToAvoid[j] then + bIsToAvoid = true + end + end + end local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if nMchType == MCH_MY.POCKETING and - dTDiam < dDiam - 10 * GEO.EPS_SMALL and + ( not bIsToAvoid) and + ( not dDiam or ( dTDiam < dDiam - 10 * GEO.EPS_SMALL)) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and ( ( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then return Drilling.Name, Drilling.Type, dTMaxDepth diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index a4de0c1..35037e8 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -27,6 +27,9 @@ local WM = require( 'WMachiningLib') -- Parametri Q local sContourOnly = 'Q01' -- 0=no, 1=si +-- Per forature MultiDrill, lista lavorazioni già provate +local TriedDrillings = {} + --------------------------------------------------------------------- -- Riconoscimento della feature @@ -56,7 +59,7 @@ end --------------------------------------------------------------------- -- Classificazione della feature -function WPD.Classify( Proc, b3Raw) +function WPD.Classify( Proc, b3Raw, bUseMultiDrill) -- recupero e verifico l'entità foro local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 @@ -75,6 +78,10 @@ function WPD.Classify( Proc, b3Raw) -- è lavorabile se non troppo inclinato return ( abs( vtExtr:getZ()) >= WD.DRILL_VZ_MIN) end + -- multiforatore (cabinet) + if bUseMultiDrill then + return true + end -- se con direzione asse Y e macchina con foratore orizzontale del giusto diametro if WD.HOR_DRILL_DIAM and abs( dDiam - WD.HOR_DRILL_DIAM) < WD.DRILL_TOL and AreSameOrOppositeVectorApprox( vtExtr, Y_AX()) then return true @@ -255,7 +262,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione -function WPD.Make( Proc, nRawId, b3Raw) +function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) -- recupero e verifico l'entità foro local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + Proc.Id end @@ -299,27 +306,35 @@ function WPD.Make( Proc, nRawId, b3Raw) end end end - local bUseDLenToFindDrilling = true - local sDrilling, nType = WM.FindDrilling( dDiam, dLen, sHead) - if not sDrilling then - bUseDLenToFindDrilling = false - sDrilling, nType = WM.FindDrilling( dDiam, nil, sHead) - end - -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata - if Proc.Double and Proc.Double == 2 then - local sDrillingBackup = sDrilling - sDrilling = WM.FindDrilling( dDiam, EgtIf( bUseDLenToFindDrilling, dLen, nil), 'H1') - if not IsMachiningOkForDouble( sDrilling) then - Proc.Double = 0 - sDrilling = sDrillingBackup - end - end - if sHead and not sDrilling then - sDrilling, nType = WM.FindDrilling( dDiam, dLen) + local sDrilling, nType + if bUseMultiDrill then + sDrilling, nType = WM.FindDrilling( nil, nil, nil, nil, true, TriedDrillings) if not sDrilling then - sDrilling, nType = WM.FindDrilling( dDiam) + return false + end + else + local bUseDLenToFindDrilling = true + sDrilling, nType = WM.FindDrilling( dDiam, dLen, sHead) + if not sDrilling then + bUseDLenToFindDrilling = false + sDrilling, nType = WM.FindDrilling( dDiam, nil, sHead) + end + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + if Proc.Double and Proc.Double == 2 then + local sDrillingBackup = sDrilling + sDrilling = WM.FindDrilling( dDiam, EgtIf( bUseDLenToFindDrilling, dLen, nil), 'H1') + if not IsMachiningOkForDouble( sDrilling) then + Proc.Double = 0 + sDrilling = sDrillingBackup + end + end + if sHead and not sDrilling then + sDrilling, nType = WM.FindDrilling( dDiam, dLen) + if not sDrilling then + sDrilling, nType = WM.FindDrilling( dDiam) + end + if sDrilling then sHead = '' end end - if sDrilling then sHead = '' end end local bAngledContourDrill = false local nAngledContourDrillId = GDB_ID.NULL @@ -446,11 +461,27 @@ function WPD.Make( Proc, nRawId, b3Raw) -- aggiungo geometria if bAngledContourDrill then EgtSetMachiningGeometry( nAngledContourDrillId) + elseif bUseMultiDrill then + if Proc.SkippedGeometries and #Proc.SkippedGeometries > 0 then + EgtSetMachiningGeometry( Proc.SkippedGeometries) + elseif Proc.OtherGeometries and #Proc.OtherGeometries > 0 then + local HolesGeometries = {} + -- aggiungo foro principale + table.insert( HolesGeometries, { AuxId, -1}) + -- aggiungo altre geometrie connesse + for i = 1, #Proc.OtherGeometries do + -- recupero geometria da lavorare + local OtherAuxId = Proc.OtherGeometries[i].Id + EgtGetInfo( Proc.OtherGeometries[i].Id, 'AUXID', 'i') + local Geometry = { OtherAuxId, -1} + table.insert( HolesGeometries, Geometry) + end + EgtSetMachiningGeometry( HolesGeometries) + end else EgtSetMachiningGeometry( {{ AuxId, -1}}) end -- eventuale inversione - if nType == 'Drill' then + if nType == 'Drill' or nType == 'MultiDrill' then EgtSetMachiningParam( MCH_MP.INVERT, bToInvert) else EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) @@ -488,7 +519,9 @@ function WPD.Make( Proc, nRawId, b3Raw) end -- imposto posizione braccio porta testa local nSCC = MCH_SCC.ADIR_ZP - if AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + if bUseMultiDrill then + nSCC = MCH_SCC.ADIR_NEAR + elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then nSCC = MCH_SCC.ADIR_YP end EgtSetMachiningParam( MCH_MP.SCC, nSCC) @@ -502,8 +535,13 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtOutLog( sMyWarn .. ' (process ' .. tostring( Proc.Id) .. ')') end end - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- leggo eventuali note esistenti della lavorazione + if bUseMultiDrill then + local sDepth = 'TH' + EgtSetMachiningParam( MCH_MP.DEPTH_STR, sDepth) + else + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + end + -- leggo eventuali note esistenti della lavorazione local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) -- se foratura o svuotatura, dichiarazione nessuna generazione sfridi per Vmill if nType == 'Drill' or nType == 'Pocket' then @@ -536,7 +574,45 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.TABMAX, 3) end -- eseguo - if not EgtApplyMachining( true, false) then + local bOk = EgtApplyMachining( true, false) + + -- in caso di fori raggruppati vengono restituiti gli eventuali fori saltati + local SkippedGeometries = {} + SkippedGeometries = EgtGetMachiningSkippedGeometry() + if bUseMultiDrill and SkippedGeometries and #SkippedGeometries > 0 then + if ( Proc.SkippedGeometries and ( #SkippedGeometries == #Proc.SkippedGeometries)) + or ( #SkippedGeometries == #Proc.OtherGeometries + 1) then + EgtRemoveOperation( nMchId) + end + Proc.SkippedGeometries = SkippedGeometries + table.insert( TriedDrillings, sDrilling) + -- per provare tutte le MultiDrill disponibili si passano quelle già fatte come lavorazioni da ignorare + bOk = WPD.Make( Proc, nRawId, b3Raw, true, TriedDrillings) + -- non trovata lavorazione, si prova con le lavorazioni singole + if not bOk then + for i = 1, #Proc.SkippedGeometries do + for j = 1, #Proc.OtherGeometries do + local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0 + if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end + local AuxIdProc = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 + if AuxIdProc then AuxIdProc = AuxIdProc + Proc.Id end + if Proc.SkippedGeometries[i][1] == AuxIdOtherGeometry then + bOk = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false) + elseif Proc.SkippedGeometries[i][1] == AuxIdProc then + bOk = WPD.Make( Proc, nRawId, b3Raw, false) + end + end + if bOk then + table.remove( Proc.SkippedGeometries, i) + end + end + end + -- TODO va gestito meglio l'output degli errorri + local _, sWarn = EgtGetMachMgrWarning( 0) + return true, sWarn + end + + if not bOk then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchId, false) return false, sErr @@ -549,6 +625,7 @@ function WPD.Make( Proc, nRawId, b3Raw) sMyWarn = (sMyWarn or sWarn) end end + -- se preforo inclinato impostato, inclinazione oltre limite impostato e foro non orizzontale if WD.PREDRILL_DIAM and WD.PREDRILL_DIAM > 0 and vtExtr:getZ() < ( WD.PREDRILL_MINANGLE or 0.707) and vtExtr:getZ() > 0.1 then -- gruppo ausiliario per preforo diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index f6e9e49..f61294f 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -2860,7 +2860,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) local dMaxSlotThicknessForBlade = 19 - local bIsSmallSlot = ( Proc.Fct == 3 and ( min( dH, dV) < dMaxSlotThicknessForBlade - 10 * GEO.EPS_SMALL) and vtN:getZ() > -0.01) + local bIsSmallSlot = ( Proc.Fct == 3 and ( min( dH, dV) < dMaxSlotThicknessForBlade - 10 * GEO.EPS_SMALL) and ( vtN:getZ() > -0.01) and ( vtN:getZ() < 0.5)) -- se di fianco if not bPckt and Proc.Fct >= 3 and ( ( vtN:getZ() < WD.NZ_MINA) or bIsSmallSlot) then -- recupero elevazione faccia in feature diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 1a5e0ec..e68fc0f 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -303,7 +303,8 @@ local function ClassifyFeatures( vProc, b3Raw) if not bOk then Proc.Flg = 0 end -- se foratura elseif Drill.Identify( Proc) then - local bOk = Drill.Classify( Proc, b3Raw) + local bUseMultiDrill = WD.USE_MULTI_DRILL or false + local bOk = Drill.Classify( Proc, b3Raw, bUseMultiDrill) if not bOk then Proc.Flg = 0 end -- se mortasatura elseif Mortise.Identify( Proc) then @@ -383,7 +384,8 @@ local function AddFeatureMachining( Proc, nRawId, b3Raw, vNLO, b3Squaring) -- se foratura ( 3/4-040-X) elseif Drill.Identify( Proc) then -- esecuzione foratura - bOk, sErr = Drill.Make( Proc, nRawId, b3Raw) + local bUseMultiDrill = WD.USE_MULTI_DRILL or false + bOk, sErr = Drill.Make( Proc, nRawId, b3Raw, bUseMultiDrill) -- se mortasatura (3/4-050-X) o similari elseif Mortise.Identify( Proc) then -- esecuzione mortasatura @@ -1086,6 +1088,30 @@ local function SetMirroredOperations() end end +------------------------------------------------------------------------------------------------------------- +function GetFeatureInfoAndDependency( vProc) + -- ciclo tutte le feature + for i = 1, #vProc do + local Proc = vProc[i] + -- controllo la feature con tutte le altre per recuperare le dipendenze + for j = 1, #vProc do + local ProcB = vProc[j] + -- se non è la stessa feature + if Proc.Id ~= ProcB.Id then + -- raggruppamento fori per eventuale Multidrill + if Drill.Identify( Proc) and Proc.Flg ~= 0 and Drill.Identify( ProcB) and ProcB.Flg ~= 0 then + if not Proc.OtherGeometries then + Proc.OtherGeometries = {} + end + table.insert( Proc.OtherGeometries, ProcB) + ProcB.Flg = 0 + ProcB.bGrouped = true + end + end + end + end +end + ------------------------------------------------------------------------------------------------------------- local function CalculateSquaring( sSquaringTool, RawPart, vPart) local dRawPartHeight = RawPart.b3:getDimZ() @@ -1205,6 +1231,8 @@ function WallExec.ProcessFeatures() local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw, b3Squaring) vProc = EgtJoinTables( vProc, vPartProc) end + -- recupero informazioni ausiliarie feature e dipendenze tra feature stesse + GetFeatureInfoAndDependency( vProc) -- classifico topologicamente le feature ClassifyTopology( vProc, nRawId) -- classifico le feature @@ -1238,7 +1266,7 @@ function WallExec.ProcessFeatures() else table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end - elseif not Proc.Double and not Proc.LockOut then + elseif not Proc.Double and not Proc.LockOut and not Proc.bGrouped then local sMsg = 'Feature not machinable by orientation' table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end From 0388dbdc0f555b09cd079fa53d3df62b5006f747 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 12 Feb 2025 11:19:23 +0100 Subject: [PATCH 2/5] - in MultiDrill piccole correzioni --- LuaLibs/WProcessDrill.lua | 2 +- LuaLibs/WallExec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 35037e8..e53519d 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -590,7 +590,7 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) bOk = WPD.Make( Proc, nRawId, b3Raw, true, TriedDrillings) -- non trovata lavorazione, si prova con le lavorazioni singole if not bOk then - for i = 1, #Proc.SkippedGeometries do + for i = #Proc.SkippedGeometries, 1, -1 do for j = 1, #Proc.OtherGeometries do local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0 if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index e68fc0f..603ce73 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1099,7 +1099,7 @@ function GetFeatureInfoAndDependency( vProc) -- se non è la stessa feature if Proc.Id ~= ProcB.Id then -- raggruppamento fori per eventuale Multidrill - if Drill.Identify( Proc) and Proc.Flg ~= 0 and Drill.Identify( ProcB) and ProcB.Flg ~= 0 then + if WD.USE_MULTI_DRILL and Drill.Identify( Proc) and Proc.Flg ~= 0 and Drill.Identify( ProcB) and ProcB.Flg ~= 0 then if not Proc.OtherGeometries then Proc.OtherGeometries = {} end From f48b40d6330eaa5a5d7715a18f0de312c71cdb4b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 13 Feb 2025 15:06:48 +0100 Subject: [PATCH 3/5] - correzioni a MultiDrill --- LuaLibs/WMachiningLib.lua | 4 ++++ LuaLibs/WProcessDrill.lua | 39 +++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index f8b3595..43cd040 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -176,6 +176,10 @@ function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets, bUseMul end end end + -- se MultiDrill non si prova il DrillPocket + if bUseMultiDrill then + return + end -- ricerca sulle svuotature, dal diametro maggiore al minore for i = #Drillings, 1, -1 do local Drilling = Drillings[i] diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index e53519d..6e304e8 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -464,16 +464,18 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) elseif bUseMultiDrill then if Proc.SkippedGeometries and #Proc.SkippedGeometries > 0 then EgtSetMachiningGeometry( Proc.SkippedGeometries) - elseif Proc.OtherGeometries and #Proc.OtherGeometries > 0 then + else local HolesGeometries = {} -- aggiungo foro principale table.insert( HolesGeometries, { AuxId, -1}) - -- aggiungo altre geometrie connesse - for i = 1, #Proc.OtherGeometries do - -- recupero geometria da lavorare - local OtherAuxId = Proc.OtherGeometries[i].Id + EgtGetInfo( Proc.OtherGeometries[i].Id, 'AUXID', 'i') - local Geometry = { OtherAuxId, -1} - table.insert( HolesGeometries, Geometry) + -- aggiungo eventuali altre geometrie connesse + if Proc.OtherGeometries and #Proc.OtherGeometries > 0 then + for i = 1, #Proc.OtherGeometries do + -- recupero geometria da lavorare + local OtherAuxId = Proc.OtherGeometries[i].Id + EgtGetInfo( Proc.OtherGeometries[i].Id, 'AUXID', 'i') + local Geometry = { OtherAuxId, -1} + table.insert( HolesGeometries, Geometry) + end end EgtSetMachiningGeometry( HolesGeometries) end @@ -581,7 +583,8 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) SkippedGeometries = EgtGetMachiningSkippedGeometry() if bUseMultiDrill and SkippedGeometries and #SkippedGeometries > 0 then if ( Proc.SkippedGeometries and ( #SkippedGeometries == #Proc.SkippedGeometries)) - or ( #SkippedGeometries == #Proc.OtherGeometries + 1) then + or ( Proc.OtherGeometries and ( #SkippedGeometries == #Proc.OtherGeometries + 1)) + or ( not Proc.OtherGeometries and #SkippedGeometries == 1) then EgtRemoveOperation( nMchId) end Proc.SkippedGeometries = SkippedGeometries @@ -591,16 +594,24 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) -- non trovata lavorazione, si prova con le lavorazioni singole if not bOk then for i = #Proc.SkippedGeometries, 1, -1 do - for j = 1, #Proc.OtherGeometries do - local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0 - if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end + if Proc.OtherGeometries then + for j = 1, #Proc.OtherGeometries do + local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0 + if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end + if Proc.SkippedGeometries[i][1] == AuxIdOtherGeometry then + bOk = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false) + break + end + end + -- se nelle altre geometrie non è stato trovato, potrebbe essere la principale local AuxIdProc = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxIdProc then AuxIdProc = AuxIdProc + Proc.Id end - if Proc.SkippedGeometries[i][1] == AuxIdOtherGeometry then - bOk = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false) - elseif Proc.SkippedGeometries[i][1] == AuxIdProc then + if Proc.SkippedGeometries[i][1] == AuxIdProc then bOk = WPD.Make( Proc, nRawId, b3Raw, false) end + -- se non ci sono altre geometrie quella da fare è sicuramente la Proc principale + else + bOk = WPD.Make( Proc, nRawId, b3Raw, false) end if bOk then table.remove( Proc.SkippedGeometries, i) From 221162ce9d94f019e19f8c74b865ace5efaec0b4 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 14 Feb 2025 11:10:31 +0100 Subject: [PATCH 4/5] correzione in forature --- LuaLibs/WProcessDrill.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 6e304e8..97c3cda 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -279,7 +279,7 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) local bOpen = ( Proc.Fcs ~= 0 and Proc.Fce ~= 0) -- verifico che il foro non sia fattibile solo da sotto local bToInvert = ( vtExtr:getZ() < -0.1) - if bToInvert and ( not bOpen or Proc.Flg ~= 1) then + if bToInvert and ( not bOpen or Proc.Flg > 1) then local sErr = 'Error : drilling from bottom impossible' EgtOutLog( sErr) return false, sErr From f434c70f22b183639063955988de4f031261b16a Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 14 Feb 2025 17:24:16 +0100 Subject: [PATCH 5/5] - correzioni a forature multiple --- LuaLibs/WProcessDrill.lua | 64 ++++++++++++++++++++++++++++----------- LuaLibs/WallExec.lua | 31 ++++++++++++++++--- 2 files changed, 72 insertions(+), 23 deletions(-) diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 97c3cda..6eafa77 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -581,6 +581,7 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) -- in caso di fori raggruppati vengono restituiti gli eventuali fori saltati local SkippedGeometries = {} SkippedGeometries = EgtGetMachiningSkippedGeometry() + local sMsgMaster if bUseMultiDrill and SkippedGeometries and #SkippedGeometries > 0 then if ( Proc.SkippedGeometries and ( #SkippedGeometries == #Proc.SkippedGeometries)) or ( Proc.OtherGeometries and ( #SkippedGeometries == #Proc.OtherGeometries + 1)) @@ -593,13 +594,21 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) bOk = WPD.Make( Proc, nRawId, b3Raw, true, TriedDrillings) -- non trovata lavorazione, si prova con le lavorazioni singole if not bOk then + local bOkMaster = true for i = #Proc.SkippedGeometries, 1, -1 do + local sErr if Proc.OtherGeometries then for j = 1, #Proc.OtherGeometries do local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0 if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end if Proc.SkippedGeometries[i][1] == AuxIdOtherGeometry then - bOk = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false) + bOk, sErr = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false) + if bOk then + Proc.OtherGeometries[j].bOk = true + else + Proc.OtherGeometries[j].bOk = false + end + Proc.OtherGeometries[j].sMsg = sErr break end end @@ -607,36 +616,55 @@ function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid) local AuxIdProc = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxIdProc then AuxIdProc = AuxIdProc + Proc.Id end if Proc.SkippedGeometries[i][1] == AuxIdProc then - bOk = WPD.Make( Proc, nRawId, b3Raw, false) + bOk, sErr = WPD.Make( Proc, nRawId, b3Raw, false) + if not bOk then + bOkMaster = false + end + sMsgMaster = sErr end -- se non ci sono altre geometrie quella da fare è sicuramente la Proc principale else - bOk = WPD.Make( Proc, nRawId, b3Raw, false) + bOk, sErr = WPD.Make( Proc, nRawId, b3Raw, false) + if not bOk then + bOkMaster = false + end + sMsgMaster = sErr end if bOk then table.remove( Proc.SkippedGeometries, i) end end + bOk = bOkMaster end - -- TODO va gestito meglio l'output degli errorri - local _, sWarn = EgtGetMachMgrWarning( 0) - return true, sWarn end - - if not bOk then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - local _, sWarn = EgtGetMachMgrWarning( 0) - if EgtIsMachiningEmpty() then - EgtSetOperationMode( nMchId, false) - return false, sWarn - else - sMyWarn = (sMyWarn or sWarn) + -- se presenti geometrie aggiuntive, aggiunta informazioni per output statistiche + if Proc.OtherGeometries and #Proc.OtherGeometries > 0 then + for i = 1, #Proc.OtherGeometries do + if Proc.OtherGeometries[i].bOk == nil then + Proc.OtherGeometries[i].bOk = true + Proc.OtherGeometries[i].sMsg = '' + end end end + if not bUseMultiDrill then + if not bOk then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + local _, sWarn = EgtGetMachMgrWarning( 0) + if EgtIsMachiningEmpty() then + EgtSetOperationMode( nMchId, false) + return false, sWarn + else + sMyWarn = (sMyWarn or sWarn) + end + end + else + return bOk, sMsgMaster + end + -- se preforo inclinato impostato, inclinazione oltre limite impostato e foro non orizzontale if WD.PREDRILL_DIAM and WD.PREDRILL_DIAM > 0 and vtExtr:getZ() < ( WD.PREDRILL_MINANGLE or 0.707) and vtExtr:getZ() > 0.1 then -- gruppo ausiliario per preforo diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 603ce73..055d634 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1161,6 +1161,19 @@ local function AddSquaring( SquaringParameters, b3Squaring) return true, sMsg end +------------------------------------------------------------------------------------------------------------- +local function AddFeatureStats( Stats, bOk, sMsg, nCutId, nTaskId) + if not bOk then + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId = nCutId, TaskId = nTaskId}) + elseif sMsg and #sMsg > 0 then + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId = nCutId, TaskId = nTaskId}) + else + table.insert( Stats, {Err=0, Msg='', Rot=0, CutId = nCutId, TaskId = nTaskId}) + end + + return Stats +end + ------------------------------------------------------------------------------------------------------------- function WallExec.ProcessFeatures() -- errori e stato @@ -1214,6 +1227,7 @@ function WallExec.ProcessFeatures() bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'Mill', RawPart, vPart) end + -- TODO sostituire con funzione if not bOk then nTotErr = nTotErr + 1 table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) @@ -1260,11 +1274,17 @@ function WallExec.ProcessFeatures() local bOk, sMsg = AddFeatureMachining( Proc, nRawId, b3Raw, vNLO, b3Squaring) if not bOk then nTotErr = nTotErr + 1 - table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) - elseif sMsg and #sMsg > 0 then - table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) - else - table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) + end + -- output statistiche feature + Stats = AddFeatureStats( Stats, bOk, sMsg, Proc.CutId, Proc.TaskId) + -- output statistiche in caso di più feature lavorate nella stessa Proc + if Proc.OtherGeometries and #Proc.OtherGeometries > 0 then + for j = 1, #Proc.OtherGeometries do + Stats = AddFeatureStats( Stats, Proc.OtherGeometries[j].bOk, Proc.OtherGeometries[j].sMsg, Proc.OtherGeometries[j].CutId, Proc.OtherGeometries[j].TaskId) + if not Proc.OtherGeometries[j].bOk then + nTotErr = nTotErr + 1 + end + end end elseif not Proc.Double and not Proc.LockOut and not Proc.bGrouped then local sMsg = 'Feature not machinable by orientation' @@ -1361,6 +1381,7 @@ function WallExec.ProcessFeatures() if SquaringParameters and next( SquaringParameters) ~= nil then local bOk, sMsg = AddSquaring( SquaringParameters, b3Squaring) + -- TODO sostituire con funzione if not bOk then nTotErr = nTotErr + 1 table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0})