diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 01872b7..b63ce3d 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -10,9 +10,8 @@ -- 2023/11/06 Migliorie e correzioni alle forature con AngularTransmission ("_AT"). -- 2024/01/18 In FindSawing aggiunto il parametro opzionale dDepth. -- 2024/01/19 In FindSawing aggiunto parametro opzionale bConsiderCSimmEncumberance per considerare l'ingombro dell'asse C nel massimo materiale (default false). --- 2024/01/22 Nella GetMachinings vengono ora raccolti i parametri utensile necessari per i VerifyTool, scritti direttamente nella tabella Machining.Tool. +-- 2024/01/23 Nella GetMachinings vengono ora raccolti i parametri utensile necessari per i VerifyTool, scritti direttamente nella tabella Machining.Tool. -- Le lavorazioni possono essere ora ordinate per dimensioni utensile (Longest, Shortest, Biggest, Smallest) se passato l'apposito parametro SortingCriterion in FindMachining. Al momento implementato solo per FindSawing. --- in GetMachinings ora si eliminano dalla lista le lavorazioni che non hanno un utensile collegato. -- Tabella per definizione modulo local MachiningLib = {} @@ -108,84 +107,60 @@ local function SetNextMachining( sToolName, nHead, bFixed) end --------------------------------------------------------------------- -local function SetCurrMachiningAndTool( sMachName) - if not EgtMdbSetCurrMachining( sMachName) then return false end - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - local sTool = EgtTdbGetToolFromUUID( sTuuid) - if not sTool then return false end - if not EgtTdbSetCurrTool( sTool) then return false end - local bActive = EgtFindToolInCurrSetup( sTool) +local function SetCurrMachiningAndTool( Machining) + EgtMdbSetCurrMachining( Machining.Name) + EgtTdbSetCurrTool( Machining.Tool.Name) + local bActive = EgtFindToolInCurrSetup( Machining.Tool.Name) local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) local nHead = tonumber( sHead:sub( 2, #sHead)) local bH2 = ( nHead >= 21 and nHead <= 29) local bH3 = ( nHead >= 31 and nHead <= 39) local bFixed = ( vFixedHeads[nHead]) - return bActive, sTool, bH2, bFixed, bH3 + return bActive, Machining.Tool.Name, bH2, bFixed, bH3 end --------------------------------------------------------------------- function VerifyDrill( Machining, dDiam, dDepth, bH2) - local dTDiam = Machining.Tool.Diameter - local dTMaxMat = Machining.Tool.MaxMat - local dMaxToolLength = Machining.Tool.TotalLength - local dDiamTh = Machining.Tool.ToolHolderDiameter - local dLen = Machining.Tool.Length - local dLenTh = 72 - if EgtTdbGetCurrToolThLength then dLenTh = EgtTdbGetCurrToolThLength() end - local dFreeLen = dLen - dLenTh - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE) - if dTDiam < dDiam + 10 * GEO.EPS_SMALL and - dTDiam > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL and - ( not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL) then - return true, { TMaxMat = dTMaxMat, MaxToolLength = dMaxToolLength, ToolDiam = dTDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} + local dFreeLen = Machining.Tool.Length - Machining.Tool.ToolHolderLength - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE) + if Machining.Tool.Diameter < dDiam + 10 * GEO.EPS_SMALL and + Machining.Tool.Diameter > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL and + ( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) then + return true, { TMaxMat = Machining.Tool.MaxMat, MaxToolLength = Machining.Tool.TotalLength, ToolDiam = Machining.Tool.Diameter, DiamTh = Machining.Tool.ToolHolderDiameter, FreeLen = dFreeLen, H2 = bH2} end end --------------------------------------------------------------------- function VerifyDrillPocket( Machining, dDiam, dDepth, bH2) - local dTDiam = Machining.Tool.Diameter - local dTMaxDepth = Machining.Tool.MaxMat - local dMaxToolLength = Machining.Tool.TotalLength - local dDiamTh = Machining.Tool.ToolHolderDiameter - local dFreeLen = dTMaxDepth - if dTDiam < dDiam - 10 * GEO.EPS_SMALL and - ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) then - return true, { TMaxDepth = dTMaxDepth, MaxToolLength = dMaxToolLength, ToolDiam = dTDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} + if Machining.Tool.Diameter < dDiam - 10 * GEO.EPS_SMALL and + ( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) then + return true, { TMaxDepth = Machining.Tool.MaxMat, MaxToolLength = Machining.Tool.TotalLength, ToolDiam = Machining.Tool.Diameter, DiamTh = Machining.Tool.ToolHolderDiameter, FreeLen = Machining.Tool.MaxMat, H2 = bH2} end end --------------------------------------------------------------------- function VerifyMill( Machining, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bH2) - local sTuuid = Machining.Tool.UUID - local dTMaxDepth = Machining.Tool.MaxMat - local dTDiam = Machining.Tool.Diameter - local dTTotLen = Machining.Tool.TotalLength - if ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and - ( not sTuuidMstr or sTuuidMstr == sTuuid) and - ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and - ( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) then - return true, { TMaxDepth = dTMaxDepth, TDiam = dTDiam, H2 = bH2} + if ( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) and + ( not sTuuidMstr or sTuuidMstr == Machining.Tool.UUID) and + ( not dMaxDiam or Machining.Tool.Diameter < dMaxDiam + GEO.EPS_SMALL) and + ( not dMaxTotLen or Machining.Tool.TotalLength < dMaxTotLen + GEO.EPS_SMALL) then + return true, { TMaxDepth = Machining.Tool.MaxMat, TDiam = Machining.Tool.Diameter, H2 = bH2} end end --------------------------------------------------------------------- function VerifyPocket( Machining, dMaxDiam, dDepth, dMaxTotLen, bH2) - local dTDiam = Machining.Tool.Diameter - local dTMaxDepth = Machining.Tool.MaxMat - local dTTotLen = Machining.Tool.TotalLength - if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and - ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and - ( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) then - return true, { TDiam = dTDiam, TMaxDepth = dTMaxDepth, H2 = bH2} + if ( not dMaxDiam or Machining.Tool.Diameter < dMaxDiam + GEO.EPS_SMALL) and + ( not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL) and + ( not dMaxTotLen or Machining.Tool.TotalLength < dMaxTotLen + GEO.EPS_SMALL) then + return true, { TDiam = Machining.Tool.Diameter, TMaxDepth = Machining.Tool.MaxMat, H2 = bH2} end end --------------------------------------------------------------------- function VerifyChainSaw( Machining, dDepth, CSimmEncumberance, bH2) - local dTMaxMat = Machining.Tool.MaxMat - local dTTotLen = Machining.Tool.TotalLength -- riduco il massimo materiale dell'ingombro asse C. Se non richiesto, arriverà un valore di CSimmEncumberance nullo - dTMaxMat = min( dTMaxMat, dTTotLen - CSimmEncumberance) - if not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL then + Machining.Tool.MaxMat = min( Machining.Tool.MaxMat, Machining.Tool.TotalLength - CSimmEncumberance) + if not dDepth or Machining.Tool.MaxMat > dDepth - GEO.EPS_SMALL then return true, { H2 = bH2} end end @@ -214,6 +189,7 @@ end --------------------------------------------------------------------- function GetMachinings( MachiningType, sType) local Machinings + -- leggo le lavorazioni disponibili if MachiningType == MCH_MY.DRILLING then Machinings = Drillings elseif MachiningType == MCH_MY.SAWING then @@ -226,6 +202,7 @@ function GetMachinings( MachiningType, sType) Machinings = Sawings end -- scrivo i parametri utensile nella lavorazione + local validMachinings = {} for i = 1, #Machinings do local Machining = Machinings[i] if EgtMdbSetCurrMachining( Machining.Name) then @@ -234,6 +211,7 @@ function GetMachinings( MachiningType, sType) Machining.Tool.Name = EgtTdbGetToolFromUUID( Machining.Tool.UUID) if Machining.Tool.Name then if EgtTdbSetCurrTool( Machining.Tool.Name) then + table.insert( validMachinings, Machining) if ( MachiningType == MCH_MY.MILLING) or ( MachiningType == MCH_MY.POCKETING) or ( MachiningType == MCH_MY.DRILLING and EgtStartsWith( sType, 'Pocket')) then Machining.Tool.MaxMat = EgtTdbGetCurrToolMaxDepth() else @@ -249,24 +227,25 @@ function GetMachinings( MachiningType, sType) end end Machining.Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam() - Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) + Machining.Tool.ToolHolderLength = EgtTdbGetCurrToolThLength() or 72 end end end end - -- rimuovo le lavorazioni senza utensile - for i, machining in ipairs( Machinings) do - if not machining.Tool.Name then - table.remove( Machinings, i) - end - end - return Machinings + -- ritorno la lista delle sole lavorazioni valide + return validMachinings end --------------------------------------------------------------------- +---restituisce la lista delle lavorazioni ordinata secondo il criterio *sCriterion* +---@param Machinings table lista della lavorazioni da riordinare +---@param sCriterion string criterio di ordinamento ('Longest', 'Shortest', 'Biggest', 'Smallest') function ReorderMachinings( Machinings, sCriterion) + + -- funzioni di ordinamento local function SortMachiningsByLongestTool( Machining1, Machining2) if Machining1.Tool.MaxMat > Machining2.Tool.MaxMat + 10 * GEO.EPS_SMALL then return true @@ -295,14 +274,21 @@ function ReorderMachinings( Machinings, sCriterion) return false end end + + -- ordinamento in base al criterio + -- ordine di default, ossia quello che arriva dal database if not sCriterion then return + -- prima gli utensili più lunghi elseif sCriterion == 'Longest' then table.sort( Machinings, SortMachiningsByLongestTool) + -- prima gli utensili più corti elseif sCriterion == 'Shortest' then table.sort( Machinings, SortMachiningsByShortestTool) + -- prima gli utensili con diametro più grande elseif sCriterion == 'Biggest' then table.sort( Machinings, SortMachiningsByBiggestTool) + -- prima gli utensili con diametro più piccolo elseif sCriterion == 'Smallest' then table.sort( Machinings, SortMachiningsBySmallestTool) end @@ -388,7 +374,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, _, sMachiningType = EgtEndsWith( Machining.Type, '_H2') end -- recupero dati utensile - local bToolActive, sToolName, bH2, bFixed, bH3 = SetCurrMachiningAndTool( Machining.Name) + local bToolActive, sToolName, bH2, bFixed, bH3 = SetCurrMachiningAndTool( Machining) if Machining.On and sMachiningType == sType and bToolActive and ( not bH2 or bH2 == not bExcludeH2) and ( not bH3 or bH3 == not bExcludeH3) then local bOk, ToolParams = VerifyTool( Machining, MachiningType, Params, bH2) if bOk then diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index ea91656..29f5f0c 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -18,7 +18,8 @@ -- Implementato split per pezzi molto alti con mix sega a catena + lama -- Implementata GetBlockedAxis che gestisce gli assi bloccati per tutti i tipi di utensile. -- 2024/01/22 Nei tagli verticali aggiuntivi si usa ora BD.MAX_LEN_DICE come dimensione (era BD.MAX_DIM_DICE). --- 2024/01/22 Nello split con sega a catena ora si cerca di preferenza una lavorazione di tipo 'SawingForSplitting'. Se non trovata si cerca il tipo 'Sawing' come in precedenza. +-- 2024/01/23 Nello split con sega a catena ora si cerca di preferenza una lavorazione di tipo 'SawingForSplitting'. Se non trovata si cerca il tipo 'Sawing' come in precedenza. +-- In split con sega a catena aggiunta estensione start/end del percorso se utensile lungo, per evitare collisioni con il pezzo durante rotazione. -- Tabella per definizione modulo local ProcessSplit = {} @@ -164,7 +165,7 @@ end --------------------------------------------------------------------- -- lavorazione con sega a catena per sezioni alte e larghe -local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, dOffs) +local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, dOffs, bExtendStartEnd) -- Recupero i dati dell'utensile local dMaxMat = 0 local dSawCornerRad = 0 @@ -200,14 +201,20 @@ local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- imposto angolo 3° asse rot EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( sSawing, 'perpendicular')) - local _, vtN = EgtSurfTmFacetCenter( nSurfId, 0, GDB_ID.ROOT) + local vtN = EgtSurfTmFacetNormVersor( nSurfId, 0, GDB_ID.ROOT) local vtOrtho = BL.GetVersRef( nFaceUse) EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) -- imposto offset radiale per mantenere il materiale in coda per la finitura EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) - -- imposto allungamento percorso iniziale e finale a zero - EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + -- imposto eventuale allungamento percorso iniziale + local dStartAddLen = 0 + local dEndAddLen = 0 + if bExtendStartEnd then + dStartAddLen = 100 + dEndAddLen = 100 + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddLen) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen) -- faccio in modo che l'attacco della lama sia dal lato opposto rispetto al corpo macchina EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) @@ -396,7 +403,13 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt if bigSectionSplitType == "single horizontal" then local dCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN local sNotesSplit = 'Split;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffs) + -- verifico se sega a catena lunga e devo quindi estendere ingresso e uscita perchè è probabile che non riesca a ruotare sopra al pezzo + local bExtendStartEnd + local dMinLengthLongChainSaw = 630 + if dChainSawLen > dMinLengthLongChainSaw - 10 * GEO.EPS_SMALL then + bExtendStartEnd = true + end + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffs, bExtendStartEnd) if not bOk then return bOk, sErr, nNewPhase end elseif bigSectionSplitType == "single vertical" then local dCutDepth = b3Raw:getDimY() + BD.CUT_EXTRA_MIN