From 92883040516bbc3381270ad8c238d1fdf4a1cf04 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 16 Feb 2026 09:41:37 +0100 Subject: [PATCH 1/3] - in ProcessDrill per fori fatti con svuotatura in doppio si limita l'affondamento (sarebbe sempre in collisione) e si aggiunge una lavorazione ad hoc, non in doppio, per l'ultimo step --- LuaLibs/BeamExec.lua | 5 +-- LuaLibs/BeamLib.lua | 34 ++++++++++++++++ LuaLibs/ProcessDrill.lua | 85 +++++++++++++++++++++++++++++----------- 3 files changed, 97 insertions(+), 27 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index bb38e0b..b3e60f7 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1980,10 +1980,7 @@ local function VerifyDrillMirrored( Proc, vProc, b3Raw) sDrilling, sType, dMaxDepth = ML.FindDrilling( dDiam, 0, true, false, true) dMachiningDepth = dMaxDepth or dMachiningDepth end - if not sDrilling - or ( sType ~= 'Drill' and ( sType ~= 'Pocket'or ( Proc.Fcs ~= 0 and Proc.Fce ~= 0))) - or not EgtMdbSetCurrMachining( sDrilling) then - + if not sDrilling or not EgtMdbSetCurrMachining( sDrilling) then return end local dDrillingStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index ee66572..282c3e1 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1403,5 +1403,39 @@ function BeamLib.GetToolFromMachining( sMachiningName) return Tool end +------------------------------------------------------------------------------------------------------------- +--- copia una tabella lua in modo ricorsivo, ossia mantiene indipendenti anche tutte le sottotabelle +--- ATTENZIONE: in caso di modifiche vanno gestiti anche i tipi custom; sarebbe meglio metterla nel LuaLibs +function BeamLib.TableCopyDeep( OriginalTable) + -- controllo se oggetto passato è valido, altrimenti errore. Non deve mai succedere + if not OriginalTable then + error( "TableCopyDeep : can't copy nil object") + end + local CopiedTable = {} + for key, value in pairs( OriginalTable) do + if type( value) == "table" then + if isBBox3d( value) then + CopiedTable[ key] = BBox3d( value) + elseif isColor3d( value) then + CopiedTable[ key] = Color3d( value) + elseif isFrame3d( value) then + CopiedTable[ key] = Frame3d( value) + elseif isPoint3d( value) then + CopiedTable[ key] = Point3d( value) + elseif isQuaternion( value) then + CopiedTable[ key] = Quaternion( value) + elseif isVector3d( value) then + CopiedTable[ key] = Vector3d( value) + else + CopiedTable[ key] = BeamLib.TableCopyDeep( value) + end + else + CopiedTable[ key] = value + end + end + + return CopiedTable +end + ------------------------------------------------------------------------------------------------------------- return BeamLib \ No newline at end of file diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 198c5a5..484afaa 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -313,6 +313,32 @@ local function GetHoleStartData( ptCen, vtExtr, b3Solid) return nFac, CosB, vFaces end +--------------------------------------------------------------------- +local function GetSCC( Proc, vtExtr, b3Solid, bDrillAngTrasm, nPhase) + local nSCC = MCH_SCC.NONE + + if bDrillAngTrasm then + nSCC = MCH_SCC.ADIR_NEAR + elseif BD.TURN == 2 then + nSCC = MCH_SCC.ADIR_ZP + elseif not BD.C_SIMM and not BD.TURN then + nSCC = MCH_SCC.ADIR_YM + if AreSameVectorApprox( vtExtr, Z_AX()) then + nSCC = MCH_SCC.ADIR_YM + elseif abs( vtExtr:getX()) < 0.1 then + local bNearTail = ( Proc.Box:getCenter():getX() < b3Solid:getCenter():getX() and Proc.Box:getCenter():getX() - b3Solid:getMin():getX() < 1000) + local bVeryShortPart = ( BD.LEN_VERY_SHORT_PART and b3Solid:getDimX() < BD.LEN_VERY_SHORT_PART) + nSCC = EgtIf( BL.IsPartFinalPhase( nPhase) or ( bNearTail and not bVeryShortPart), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + elseif vtExtr:getY() > 0.1 then + nSCC = MCH_SCC.ADIR_YP + end + else + nSCC = MCH_SCC.NONE + end + + return nSCC +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) @@ -588,6 +614,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dDepth = dMaxDepth dMaxElev = dMaxDepth end + -- inserisco la lavorazione local sName = EgtIf( EgtStartsWith( sType, 'Predrill'), 'Predrill_', 'Drill_') .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sDrilling) @@ -605,31 +632,21 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) end -- imposto posizione braccio porta testa - local nSCC = MCH_SCC.NONE - if bDrillAngTrasm then - nSCC = MCH_SCC.ADIR_NEAR - elseif BD.TURN == 2 then - nSCC = MCH_SCC.ADIR_ZP - elseif not BD.C_SIMM and not BD.TURN then - nSCC = MCH_SCC.ADIR_YM - if AreSameVectorApprox( vtExtr, Z_AX()) then - nSCC = MCH_SCC.ADIR_YM - elseif abs( vtExtr:getX()) < 0.1 then - local bNearTail = ( Proc.Box:getCenter():getX() < b3Solid:getCenter():getX() and Proc.Box:getCenter():getX() - b3Solid:getMin():getX() < 1000) - local bVeryShortPart = ( BD.LEN_VERY_SHORT_PART and b3Solid:getDimX() < BD.LEN_VERY_SHORT_PART) - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase) or ( bNearTail and not bVeryShortPart), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) - elseif vtExtr:getY() > 0.1 then - nSCC = MCH_SCC.ADIR_YP - end - else - nSCC = MCH_SCC.NONE - end + local nSCC = GetSCC( Proc, vtExtr, b3Solid, bDrillAngTrasm, nPhase) EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- imposto affondamento - if Proc.Double and Proc.Double > 0 and dDepth > Proc.MachDepthDouble + 10 * GEO.EPS_SMALL then - sMyWarn = 'Warning in double head drilling : depth (' .. EgtNumToString( dDepth, 1) .. ') reduced to (' .. EgtNumToString( Proc.MachDepthDouble, 1) .. ') to match H2 max tool depth' - dDepth = Proc.MachDepthDouble - dMaxElev = Proc.MachDepthDouble + local dLastStepDepth + if Proc.Double and Proc.Double > 0 then + if ( sType == 'Pocket_AT' or sType == 'Pocket') and bOpen then + local dReduceDepth = MIRROR_DRILLINGS_MIN_DISTANCE / 2 + 10 + dLastStepDepth = dDepth + dReduceDepth + dDepth = dDepth - dReduceDepth + end + if dDepth > Proc.MachDepthDouble + 10 * GEO.EPS_SMALL then + sMyWarn = 'Warning in double head drilling : depth (' .. EgtNumToString( dDepth, 1) .. ') reduced to (' .. EgtNumToString( Proc.MachDepthDouble, 1) .. ') to match H2 max tool depth' + dDepth = Proc.MachDepthDouble + dMaxElev = Proc.MachDepthDouble + end end EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- imposto il valore della distanza di sicurezza per l'attacco. Se il valore del db utensili è troppo basso lo alzo a 10. @@ -676,6 +693,28 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) EgtSetOperationMode( nMchId, false) return false, sWarn else + -- se DrillPocket passante in doppio si fa lavorazione aggiuntiva dell'ultimo step + if Proc.Double and Proc.Double > 0 and ( sType == 'Pocket_AT' or sType == 'Pocket') and bOpen then + local nAddGrpId = BL.GetAddGroup( Proc.PartId) + local idProcLastStep = EgtCopyGlob( Proc.Id, nAddGrpId) + local idAuxIdLastStep = EgtCopyGlob( AuxId, nAddGrpId) + EgtModifyCurveThickness( idAuxIdLastStep, -dLastStepDepth) + local ProcLastStep = BL.TableCopyDeep( Proc) + ProcLastStep.Id = idProcLastStep + ProcLastStep.Flg = 1 + ProcLastStep.Double = 0 + Proc.dCustomMaxElev = MIRROR_DRILLINGS_MIN_DISTANCE + local bOkLastStep, sWarnLastStep = ProcessDrill.Make( ProcLastStep, nPhase, nRawId, nPartId) + if not bOkLastStep then + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end + sMyWarn = 'Drillpocket double : last step missing;\n' .. ( sMyWarn or sWarn or '') + else + sMyWarn = sWarnLastStep .. '\n' .. ( sMyWarn or sWarn or '') + end + end return true, ( sMyWarn or sWarn) end end From 394fb2194f3a27d47c541ed1aa323ad74cee00de Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 16 Feb 2026 12:10:46 +0100 Subject: [PATCH 2/3] - in ProcessDrilling correzioni e migliorie alla lavorazione ultimo step di fori svuotati in doppio --- LuaLibs/ProcessDrill.lua | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 484afaa..1422d55 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -638,7 +638,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local dLastStepDepth if Proc.Double and Proc.Double > 0 then if ( sType == 'Pocket_AT' or sType == 'Pocket') and bOpen then - local dReduceDepth = MIRROR_DRILLINGS_MIN_DISTANCE / 2 + 10 + local dReduceDepth = MIRROR_POCKETS_MIN_DISTANCE / 2 + 10 dLastStepDepth = dDepth + dReduceDepth dDepth = dDepth - dReduceDepth end @@ -658,8 +658,16 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) or '' sUserNotes = EgtSetValInNotes( sUserNotes, 'VMRS', 0) -- aggiungo alle note massima elevazione (coincide con affondamento) - if dMaxElev then - sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dMaxElev, 1)) + local dCustomMaxElev + if Proc.dCustomMaxElev and type( Proc.dCustomMaxElev) == "number" and Proc.dCustomMaxElev > 10 * GEO.EPS_SMALL then + dCustomMaxElev = Proc.dCustomMaxElev + end + if dMaxElev or dCustomMaxElev then + if dCustomMaxElev then + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dCustomMaxElev, 1)) + else + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dMaxElev, 1)) + end end -- se foro passante, aggiungo questa qualifica alle note if ( sType == 'Drill' or sType == 'Drill_H2' or sType == 'AngleDrill') and bOpen then @@ -685,7 +693,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end if not bOk then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMchId, false) return false, sErr else local _, sWarn = EgtGetMachMgrWarning( 0) @@ -703,16 +711,15 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) ProcLastStep.Id = idProcLastStep ProcLastStep.Flg = 1 ProcLastStep.Double = 0 - Proc.dCustomMaxElev = MIRROR_DRILLINGS_MIN_DISTANCE + ProcLastStep.dCustomMaxElev = dDepth local bOkLastStep, sWarnLastStep = ProcessDrill.Make( ProcLastStep, nPhase, nRawId, nPartId) if not bOkLastStep then - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - sMyWarn = 'Drillpocket double : last step missing;\n' .. ( sMyWarn or sWarn or '') - else - sMyWarn = sWarnLastStep .. '\n' .. ( sMyWarn or sWarn or '') + sWarnLastStep = 'Drillpocket double : incomplete, last step missing' + end + local sPreviousWarn = sMyWarn or sWarn + if sWarnLastStep then + if not sPreviousWarn then sPreviousWarn = '' end + sMyWarn = EgtIf( #sPreviousWarn > 0, sPreviousWarn .. '\n' .. sWarnLastStep, sWarnLastStep) end end return true, ( sMyWarn or sWarn) From 51a8ad95b23f7bd64e44f40a67834b9d5231e5af Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 16 Feb 2026 13:27:35 +0100 Subject: [PATCH 3/3] - in ProcessDrill correzione in LastStep --- LuaLibs/ProcessDrill.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 1422d55..adaf08c 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -711,7 +711,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) ProcLastStep.Id = idProcLastStep ProcLastStep.Flg = 1 ProcLastStep.Double = 0 - ProcLastStep.dCustomMaxElev = dDepth + ProcLastStep.dCustomMaxElev = dLastStepDepth - dDepth local bOkLastStep, sWarnLastStep = ProcessDrill.Make( ProcLastStep, nPhase, nRawId, nPartId) if not bOkLastStep then sWarnLastStep = 'Drillpocket double : incomplete, last step missing'