From a27566031bb5be4051d65ac2a3f45e39cccabaf0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 11 Feb 2025 18:46:10 +0100 Subject: [PATCH] - 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