From 8d80f389d3eacc180a8a3dffa104698b5bb396c2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 22 Jan 2024 16:34:39 +0100 Subject: [PATCH 1/6] - In MachiningLib -> FindSawing aggiunto parametro opzionale bConsiderCSimmEncumberance per considerare l'ingombro dell'asse C nel massimo materiale (default false). - In MachiningLib -> 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 HeadCut e Split, nei tagli verticali aggiuntivi, si usa ora BD.MAX_LEN_DICE come dimensione (era BD.MAX_DIM_DICE). - In LapJoint e LongCut implementata gestione seghe a catena multiple. --- LuaLibs/MachiningLib.lua | 182 +++++++++++++++++++++++++++--------- LuaLibs/ProcessHeadCut.lua | 3 +- LuaLibs/ProcessLapJoint.lua | 22 ++++- LuaLibs/ProcessLongCut.lua | 7 +- LuaLibs/ProcessSplit.lua | 31 ++---- 5 files changed, 171 insertions(+), 74 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 43eec69..55f2bb6 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -9,6 +9,9 @@ -- 2023/07/28 Aggiunta gestione del tipo di foratura "Drill_AT". -- 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. +-- 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. -- Tabella per definizione modulo local MachiningLib = {} @@ -114,48 +117,47 @@ local function SetCurrMachiningAndTool( sMachName) 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 bH3 = ( nHead >= 31 and nHead <= 39) local bFixed = ( vFixedHeads[nHead]) return bActive, sTool, bH2, bFixed, bH3 end --------------------------------------------------------------------- -function VerifyDrill( dDiam, dDepth, bH2) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) - local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dDiamTh = EgtTdbGetCurrToolThDiam() +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 = EgtTdbGetCurrToolParam( MCH_TP.LEN) - dLenTh - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE) + 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 = dToolDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} + return true, { TMaxMat = dTMaxMat, MaxToolLength = dMaxToolLength, ToolDiam = dTDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} end end --------------------------------------------------------------------- -function VerifyDrillPocket( dDiam, dDepth, bH2) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dDiamTh = EgtTdbGetCurrToolThDiam() +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 = dToolDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} + return true, { TMaxDepth = dTMaxDepth, MaxToolLength = dMaxToolLength, ToolDiam = dTDiam, DiamTh = dDiamTh, FreeLen = dFreeLen, H2 = bH2} end end --------------------------------------------------------------------- -function VerifyMill( dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bH2) - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) +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 @@ -165,10 +167,10 @@ function VerifyMill( dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bH2) end --------------------------------------------------------------------- -function VerifyPocket( dMaxDiam, dDepth, dMaxTotLen, bH2) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) +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 @@ -177,39 +179,127 @@ function VerifyPocket( dMaxDiam, dDepth, dMaxTotLen, bH2) end --------------------------------------------------------------------- -function VerifyTool( MachiningType, sType, Params, bH2) +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 + return true, { H2 = bH2} + end +end + +--------------------------------------------------------------------- +function VerifyTool( Machining, MachiningType, Params, bH2) if MachiningType == MCH_MY.DRILLING then - if EgtStartsWith( sType, 'Drill') or EgtStartsWith( sType, 'AngleDrill') then - return VerifyDrill( Params.Diam, Params.Depth, bH2) - elseif EgtStartsWith( sType, 'Pocket') then - return VerifyDrillPocket( Params.Diam, Params.Depth, bH2) + if Machining.SubType == 'Drill' or Machining.SubType == 'AngleDrill' then + return VerifyDrill( Machining, Params.Diam, Params.Depth, bH2) + elseif Machining.SubType == 'DrillPocket' then + return VerifyDrillPocket( Machining, Params.Diam, Params.Depth, bH2) end elseif MachiningType == MCH_MY.SAWING then return true, { H2 = bH2} elseif MachiningType == MCH_MY.MILLING then - return VerifyMill( Params.Depth, Params.TuuidMstr, Params.MaxDiam, Params.MaxTotLen, bH2) + return VerifyMill( Machining, Params.Depth, Params.TuuidMstr, Params.MaxDiam, Params.MaxTotLen, bH2) elseif MachiningType == MCH_MY.POCKETING then - return VerifyPocket( Params.MaxDiam, Params.Depth, Params.MaxTotLen, bH2) + return VerifyPocket( Machining, Params.MaxDiam, Params.Depth, Params.MaxTotLen, bH2) elseif MachiningType == MCH_MY.MORTISING then - return true, { H2 = bH2} + return VerifyChainSaw( Machining, Params.Depth, Params.CSimmEncumberance, bH2) else return false end end --------------------------------------------------------------------- -function GetMachinings( MachiningType) +function GetMachinings( MachiningType, sType) + local Machinings if MachiningType == MCH_MY.DRILLING then - return Drillings + Machinings = Drillings elseif MachiningType == MCH_MY.SAWING then - return Cuttings + Machinings = Cuttings elseif MachiningType == MCH_MY.MILLING then - return Millings + Machinings = Millings elseif MachiningType == MCH_MY.POCKETING then - return Pocketings + Machinings = Pocketings elseif MachiningType == MCH_MY.MORTISING then - return Sawings + Machinings = Sawings end + -- scrivo i parametri utensile nella lavorazione + for i = 1, #Machinings do + local Machining = Machinings[i] + if EgtMdbSetCurrMachining( Machining.Name) then + Machining.Tool = {} + Machining.Tool.UUID = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + Machining.Tool.Name = EgtTdbGetToolFromUUID( Machining.Tool.UUID) + if Machining.Tool.Name then + if EgtTdbSetCurrTool( Machining.Tool.Name) then + 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 + Machining.Tool.MaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + end + if MachiningType == MCH_MY.DRILLING then + if EgtStartsWith( Machining.Type, 'Drill') then + Machining.SubType = 'Drill' + elseif EgtStartsWith( Machining.Type, 'AngleDrill') then + Machining.SubType = 'AngleDrill' + elseif EgtStartsWith( Machining.Type, 'Pocket') then + Machining.SubType = 'DrillPocket' + end + end + Machining.Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam() + Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) + end + end + end + end + return Machinings +end + +--------------------------------------------------------------------- +function ReorderMachinings( Machinings, sCriterion) + local function SortMachiningsByLongestTool( Machining1, Machining2) + if Machining1.Tool.MaxMat > Machining2.Tool.MaxMat + 10 * GEO.EPS_SMALL then + return true + else + return false + end + end + local function SortMachiningsByShortestTool( Machining1, Machining2) + if Machining1.Tool.MaxMat < Machining2.Tool.MaxMat - 10 * GEO.EPS_SMALL then + return true + else + return false + end + end + local function SortMachiningsByBiggestTool( Machining1, Machining2) + if Machining1.Tool.Diameter > Machining2.Tool.Diameter + 10 * GEO.EPS_SMALL then + return true + else + return false + end + end + local function SortMachiningsBySmallestTool( Machining1, Machining2) + if Machining1.Tool.Diameter < Machining2.Tool.Diameter - 10 * GEO.EPS_SMALL then + return true + else + return false + end + end + if not sCriterion then + return + elseif sCriterion == 'Longest' then + table.sort( Machinings, SortMachiningsByLongestTool) + elseif sCriterion == 'Shortest' then + table.sort( Machinings, SortMachiningsByShortestTool) + elseif sCriterion == 'Biggest' then + table.sort( Machinings, SortMachiningsByBiggestTool) + elseif sCriterion == 'Smallest' then + table.sort( Machinings, SortMachiningsBySmallestTool) + end + end --------------------------------------------------------------------- @@ -229,7 +319,7 @@ function ReturnParams( MachiningType, MachiningName, sType, ToolParams) end --------------------------------------------------------------------- -local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, bExcludeH2, bExcludeH3) +local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) if bTopHead == nil and bDownHead == nil then bTopHead = true bDownHead = false @@ -256,11 +346,12 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, local sH2Mach = '' local sH2Tool = '' local sH2Param - -- ricerca sulle forature, dal diametro maggiore al minore - local Machinings = GetMachinings( MachiningType) + local Machinings = GetMachinings( MachiningType, sType) + ReorderMachinings( Machinings, sSortingCriterion) local ForStart = 1 local ForEnd = #Machinings local ForStep = 1 + -- le forature vanno scorse dal diametro maggiore al minore if MachiningType == MCH_MY.DRILLING then ForStart = #Machinings ForEnd = 1 @@ -292,7 +383,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, -- recupero dati utensile local bToolActive, sToolName, bH2, bFixed, bH3 = SetCurrMachiningAndTool( Machining.Name) 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( MachiningType, sType, Params, bH2) + local bOk, ToolParams = VerifyTool( Machining, MachiningType, Params, bH2) if bOk then if MachineHeadUse == ONE_HEAD then SetNextMachining( sToolName, 1, bFixed) @@ -411,8 +502,9 @@ function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth, dMaxTotLen, bTopHe end --------------------------------------------------------------------- -function MachiningLib.FindSawing( sType, dDepth) - return FindMachining( MCH_MY.MORTISING, sType, { Depth = dDepth}) +function MachiningLib.FindSawing( sType, dDepth, bConsiderCSimmEncumberance, sSortingCriterion) + if not BD.C_SIMM_ENC then BD.C_SIMM_ENC = EgtIf( BD.C_SIMM, 180, 90) end + return FindMachining( MCH_MY.MORTISING, sType, { Depth = dDepth, CSimmEncumberance = EgtIf( bConsiderCSimmEncumberance, BD.C_SIMM_ENC, 0)}, nil, nil, nil, nil, sSortingCriterion) end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index a18538d..dbfbafb 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -10,6 +10,7 @@ -- 2023/08/02 Corretto calcolo allungamenti/accorciamenti pezzi alti per contemplare anche taglio singolo -- 2023/10/17 Corretto calcolo allungamenti/accorciamenti per evitare lunghezze del percorso negative -- 2024/01/18 Gestiti tagli verticali aggiuntivi per travi larghe. +-- 2024/01/22 Nei tagli verticali aggiuntivi si usa ora BD.MAX_LEN_DICE come dimensione (era BD.MAX_DIM_DICE). -- Tabella per definizione modulo local ProcessHeadCut = {} @@ -157,7 +158,7 @@ end -- tagli verticali aggiuntivi local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw ) local _, dimH = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) - local nVerticalCuts = ceil( dimH / ( BD.MAX_DIM_DICE)) - 1 + local nVerticalCuts = ceil( dimH / ( BD.MAX_LEN_DICE)) - 1 local dVerticalSliceHeight = dimH / ( nVerticalCuts + 1) -- recupero il diametro dell'utensile local dSawDiam = 400 diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 4978f5f..10e5ac8 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -88,6 +88,7 @@ -- 2023/12/01 In MakeMoreFaces, nelle OpenPocket, ammesso utensile con diametro fino a 3 volte la dimensione della tasca (era 2). -- 2023/12/06 In VerifySideMillAsSaw, se SIDEDEPTH non definita, viene calcolata. -- 2024/01/18 Implementata GetBlockedAxis che gestisce gli assi bloccati per tutti i tipi di utensile. +-- 2024/01/22 Implementata gestione seghe a catena multiple. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -310,10 +311,15 @@ local function TestElleShape4( Proc) end --------------------------------------------------------------------- -local function VerifyChainSaw( Proc, dMinDim, dMaxDim) +local function VerifyChainSaw( Proc, dMinDim, dMaxDim, dDepth) local bUseChainSaw = false local sMchFind = 'Sawing' - local sSawing = ML.FindSawing( sMchFind) + -- prendo la prima sega a catena lunga a sufficienza + local sSawing = ML.FindSawing( sMchFind, dDepth, true) + -- se non trovo alcuna sega a catena lunga a sufficienza, accetto di non arrivare sul fondo della tasca + if not sSawing then + sSawing = ML.FindSawing( sMchFind, nil, nil, 'Longest') + end local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 @@ -2697,6 +2703,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, if nOk < 0 then return false, sErr end end end + if not dDepth then dDepth = dElev end -- Recupero le facce adiacenti alla principale local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] if not vAdj or #vAdj == 0 then @@ -2830,7 +2837,12 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- altrimenti con sega a catena else -- Recupero la lavorazione - local sSawing = ML.FindSawing( 'Sawing') + local sSawing = ML.FindSawing( 'Sawing', dDepth, true) + -- se non trovo alcuna sega a catena lunga a sufficienza, accetto di non arrivare sul fondo della tasca + if not sSawing then + sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + end + -- se non trova una lavorazione di sawing esco if not sSawing then local sErr = 'Error : Sawing not found in library' EgtOutLog( sErr) @@ -2948,7 +2960,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- altrimenti sega a catena di fianco else -- verifico se posso farlo con la sega-catena - local bMakeChainSaw, sSawing2, dMaxMat2, dSawCornerRad2, dSawThick2 = VerifyChainSaw( Proc, dDimMin, dDimMax) + local bMakeChainSaw, sSawing2, dMaxMat2, dSawCornerRad2, dSawThick2 = VerifyChainSaw( Proc, dDimMin, dDimMax, dDepth) if bMakeChainSaw then -- Calcolo normale faccia da lavorare local vtNL = EgtSurfTmFacetNormVersor( Proc.Id, nLundIdFace, GDB_ID.ROOT) @@ -4541,7 +4553,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- Se la svuotatura precedente non è stata fatta e chamfer non è mutuamente esclusivo provo con la sega-catena if bTryWithBlades and nChamfer < 2 then -- verifico se posso farlo con la sega-catena - local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifyChainSaw( Proc, dDimMin, dDimMax) + local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifyChainSaw( Proc, dDimMin, dDimMax, dDepth) if bMakeChainSaw then -- Ricalcolo l'affondamento tenendo conto di eventuale inclinazione local dSlDepth diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 7a8a305..259e41d 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -33,6 +33,7 @@ -- 2023/10/24 Migliorata spezzatura taglio passante con due spezzoni -- 2023/11/30 Calcolo elevazione velocizzato e centralizzato tramite la funzione GetFaceElevation. -- 2024/01/18 Implementata GetBlockedAxis che gestisce gli assi bloccati per tutti i tipi di utensile. +-- 2024/01/22 Implementata gestione seghe a catena multiple. -- Tabella per definizione modulo local ProcessLongCut = {} @@ -500,7 +501,11 @@ end -- lavorazione faccia laterale con sega a catena local function MakeSideFaceByChainSaw( nSurfId, dDepth, dOffs, dSal, dEal, bShortenStart, bShortenEnd) -- Recupero i dati dell'utensile - local sSawing = ML.FindSawing( 'Sawing') + local sSawing = ML.FindSawing( 'Sawing', dDepth, true) + -- se non trovo alcuna sega a catena lunga a sufficienza, accetto di non arrivare sul fondo + if not sSawing then + sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + end local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index edad1e6..7c780a3 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -17,6 +17,7 @@ -- 2024/01/18 Gestita lama con aggregato con asse bloccato per massimizzare capacità di taglio verticale, se da sotto -- 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). -- Tabella per definizione modulo local ProcessSplit = {} @@ -162,9 +163,8 @@ end --------------------------------------------------------------------- -- lavorazione con sega a catena per sezioni alte e larghe -local function MakeSplitByChainSaw( nSurfId, nFaceUse, dDepth, sNotes, dOffs) +local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, dOffs) -- Recupero i dati dell'utensile - local sSawing = ML.FindSawing( 'Sawing') local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 @@ -249,7 +249,7 @@ end -- tagli verticali aggiuntivi local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw ) local _, dimH = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) - local nVerticalCuts = ceil( dimH / ( BD.MAX_DIM_DICE)) - 1 + local nVerticalCuts = ceil( dimH / ( BD.MAX_LEN_DICE)) - 1 local dVerticalSliceHeight = dimH / ( nVerticalCuts + 1) -- recupero il diametro dell'utensile local dSawDiam = 400 @@ -355,7 +355,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local bFinishingNeeded = false if bSplit then -- recupero dati utensile della sega a catena più lunga a disposizione - local sSawing = ML.FindSawing( 'Sawing') + local sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') local dChainSawMaxMat = 0 local dChainSawLen = 0 if EgtMdbSetCurrMachining( sSawing or '') then @@ -365,19 +365,6 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt dChainSawLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dChainSawLen end end - local sSawing2 = ML.FindSawing( 'Sawing', dChainSawMaxMat + 1) - if sSawing2 then - sSawing = sSawing2 - dChainSawMaxMat = 0 - dChainSawLen = 0 - if EgtMdbSetCurrMachining( sSawing or '') then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dChainSawMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dChainSawMaxMat - dChainSawLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dChainSawLen - end - end - end local bigSectionSplitType -- se pezzo non troppo alto, taglio singolo da sopra @@ -405,26 +392,26 @@ 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, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffs) + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffs) if not bOk then return bOk, sErr, nNewPhase end elseif bigSectionSplitType == "single vertical" then local dCutDepth = b3Raw:getDimY() + BD.CUT_EXTRA_MIN local sNotesSplit = 'Split;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) if not bOk then return bOk, sErr, nNewPhase end elseif bigSectionSplitType == "double vertical" then local dCutDepth = 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN local sNotesSplit = 'Presplit;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_BACK, dCutDepth, sNotesSplit, dOffs) + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_BACK, dCutDepth, sNotesSplit, dOffs) if not bOk then return bOk, sErr, nNewPhase end sNotesSplit = 'Split;' - bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) + bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) if not bOk then return bOk, sErr, nNewPhase end elseif bigSectionSplitType == "double horizontal" then -- sega a catena da sopra local dChainSawCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN - dSawMaxDepth2 local sNotesSplit = 'Presplit;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_TOP, dChainSawCutDepth, sNotesSplit, dOffs) + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dChainSawCutDepth, sNotesSplit, dOffs) if not bOk then return bOk, sErr, nNewPhase end -- lama da sotto local dCutExtra = -dChainSawCutDepth + BD.CUT_EXTRA_MIN From 337e13dbde010bb455ce19a34714853cedb95bcd Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 22 Jan 2024 18:14:18 +0100 Subject: [PATCH 2/6] In 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. --- LuaLibs/ProcessSplit.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index 7c780a3..ea91656 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -18,6 +18,7 @@ -- 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. -- Tabella per definizione modulo local ProcessSplit = {} @@ -355,7 +356,10 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local bFinishingNeeded = false if bSplit then -- recupero dati utensile della sega a catena più lunga a disposizione - local sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + local sSawing = ML.FindSawing( 'SawingForSplitting', nil, nil, 'Longest') + if not sSawing then + sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + end local dChainSawMaxMat = 0 local dChainSawLen = 0 if EgtMdbSetCurrMachining( sSawing or '') then From 418fb4e284e71966476f8b90408531a754993cd4 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 23 Jan 2024 10:39:40 +0100 Subject: [PATCH 3/6] - correzione in MachiningLib per gestire il caso in cui una lavorazione sia attiva ma non ha alcun utensile collegato --- LuaLibs/MachiningLib.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 55f2bb6..f5eb317 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -255,6 +255,12 @@ function GetMachinings( MachiningType, sType) 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 end From 0400878279d716787fc46aecce750f580431c17e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 23 Jan 2024 10:42:17 +0100 Subject: [PATCH 4/6] update commenti --- LuaLibs/MachiningLib.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index f5eb317..01872b7 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -12,6 +12,7 @@ -- 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. -- 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 = {} From 4a408e3f619839fcec77381d77c64412d155aa3d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 24 Jan 2024 11:46:13 +0100 Subject: [PATCH 5/6] DataBeam 2.6a1 : - modifiche per poter impostare offset intermedio anche se lanciato da EgtCam5 - corretto calcolo cubetti con superficie limitante parallela e opposta a quella di base - modifiche a Split per tagli a cubetti su grandi sezioni. --- BatchProcess.lua | 2 +- BatchProcessNew.lua | 2 +- LuaLibs/BeamExec.lua | 23 +++++++++++++++++------ LuaLibs/DiceCut.lua | 4 ++-- LuaLibs/ProcessSplit.lua | 16 +++++++++------- Process.lua | 17 +++++++++++++---- Version.lua | 6 +++--- 7 files changed, 46 insertions(+), 24 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index f666518..b8f9d3c 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -357,7 +357,7 @@ if bToProcess then local dOvmHead = vBeam[1].PosX or 0 -- Sistemo le travi nel grezzo - local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) + local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, nil, vBeam) if not bPbOk then BEAM.ERR = 18 BEAM.MSG = sPbErr diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index b40afe1..3d32ed0 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -405,7 +405,7 @@ if bToProcess then end -- Sistemo le travi nel grezzo - local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, BEAM.FLAG == 6) + local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, nil, vBeam, BEAM.FLAG == 6) if not bPbOk then BEAM.ERR = 18 BEAM.MSG = sPbErr diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index ee06769..93bd6f6 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -517,12 +517,15 @@ local function VerifyBigSectionCut( dRawW, dRawH) end ------------------------------------------------------------------------------------------------------------- -function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroupOk) +function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, bMachGroupOk) -- default per nuove costanti qualora non definite BD.OVM_BLADE_HBEAM = ( BD.OVM_BLADE_HBEAM or 11) BD.OVM_CHAIN_HBEAM = ( BD.OVM_CHAIN_HBEAM or 8) - + + -- sovramateriale intermedio nullo se non definito + dOvmMid = ( dOvmMid or 0) + -- Determinazione minimo grezzo scaricabile BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) @@ -579,8 +582,12 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroup local lastB3Solid = nil local dOffset = dOvmHead if i > 1 then - lastB3Solid = vBeam[i-1].Box - dOffset = vBeam[i].PosX - vBeam[i-1].PosX - lastB3Solid:getDimX() + if vBeam[i].PosX then + lastB3Solid = vBeam[i-1].Box + dOffset = vBeam[i].PosX - vBeam[i-1].PosX - lastB3Solid:getDimX() + else + dOffset = dOvmMid + end end -- analizzo le features per valutare l'esistenza di feature head/tail che renderebbero inutili le rispettive finiture o di tagli di testa/coda sostituiti da cui leggere il parametro Q05 local vProc = CollectFeatures( Pz, b3Solid, 0) @@ -615,8 +622,12 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroup ( abs( PartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and NextLen + DeltaE >= 0 then -- eventuale sovramateriale di testa - if i > 1 and vBeam[i].PosX then - DeltaS = max( vBeam[i].PosX - ( dRawL - Len), DeltaSMin) + if i > 1 then + if vBeam[i].PosX then + DeltaS = max( vBeam[i].PosX - ( dRawL - Len), DeltaSMin) + else + DeltaS = max( dOvmMid - DeltaE, 0) + end end -- dimensioni del grezzo local CrawLen = min( PartLen + DeltaS + DeltaE, Len) diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index c8bb109..d53cad2 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -1,4 +1,4 @@ --- DiceCut.lua by Egaltech s.r.l. 2023/06/29 +-- DiceCut.lua by Egaltech s.r.l. 2024/01/23 -- Gestione dei piano paralleli nei tagli lunghi: equidistanziamento dei piani paralleli -- Tabella per definizione modulo @@ -396,7 +396,7 @@ function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPl end local dElevP = DistanzaMassima( nParent, ptCPlanes, vtNPlanes, ptCBond, vtNBond, BBoxRawPart, TBoxPoint) local dElevO - if ptCBond and vtNBond then + if ptCBond and vtNBond and not AreOppositeVectorApprox( vtNBond, vtNPlanes) then dElevO = DistanzaMassima( nParent, ptCBond, vtNBond, ptCPlanes, vtNPlanes, BBoxRawPart, TBoxPoint) end diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index ea91656..e03be69 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -248,7 +248,7 @@ end --------------------------------------------------------------------- -- tagli verticali aggiuntivi -local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw ) +local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes) local _, dimH = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) local nVerticalCuts = ceil( dimH / ( BD.MAX_LEN_DICE)) - 1 local dVerticalSliceHeight = dimH / ( nVerticalCuts + 1) @@ -261,11 +261,11 @@ local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw ) end end local bOk, sErr - -- tagli orizzontali + -- tagli verticali for j = nVerticalCuts, 1, -1 do local nFaceUse = MCH_MILL_FU.PARAL_FRONT local dVerticalCutOffset = dVerticalSliceHeight * -j - bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, '', b3Raw) + bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, sNotes, b3Raw) if not bOk then return bOk, sErr end end return bOk, sErr @@ -344,7 +344,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt if nNextRawId and EgtVerifyRawPartPhase( nNextRawId, nPhase) then local b3NextRaw = EgtGetRawPartBBox( nNextRawId) dLenEndRaw = ptC:getX() - b3NextRaw:getMin():getX() - nCuts = ceil( dLenEndRaw / ( BD.MAX_LEN_SCRAP + 0.5)) + nCuts = ceil( dLenEndRaw / ( EgtIf( bBigSectionCut, BD.MAX_DIM_DICE - 0.1, BD.MAX_LEN_SCRAP + 0.5))) dOffsL = dLenEndRaw / nCuts -- aggiorno ingombro del grezzo corrente con quello del successivo b3Raw:Add( b3NextRaw) @@ -504,7 +504,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt if AreOppositeVectorApprox( X_AX(), vtNLimitingSurf) then EgtInvertSurf( nLimitingSurf) end end -- tagli verticali - bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw) + bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw, sNotes) if not bOk then return bOk, sErr end -- tagli a cubetti con eventuale superficie limitante bOk, sErr = Cut.Make( AddProc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT, nil, nLimitingSurf) @@ -629,7 +629,8 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local dCutOffset = ( i - 1) * dOffsL -- se trave larga effettuo tagli verticali aggiuntivi if not bSplit and ( dimH > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) then - local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw) + local sSpecNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw, sSpecNotes) if not bOk then return bOk, sErr end end local sNotes @@ -680,7 +681,8 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local dCutOffset = ( i - 1) * dOffsL -- se trave larga effettuo tagli verticali aggiuntivi if not bSplit and ( dimH > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) then - local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw) + local sSpecNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw, sSpecNotes) if not bOk then return bOk, sErr end end local sNotes diff --git a/Process.lua b/Process.lua index 37b89be..ea714f4 100644 --- a/Process.lua +++ b/Process.lua @@ -140,6 +140,7 @@ local function MyProcessBeams() ', Lmax='..EgtNumToString( BD.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BD.MinRaw + BD.OVM_MID, 0)..')', {'Lunghezza grezzo', EgtNumToString( BD.STD_RAW, 0)}, {'Sovramateriale di testa', EgtNumToString( BD.OVM_HEAD, 0)}, + {'Offset intermedio', EgtNumToString( BD.OVM_MID, 0)}, {'Forza sezione verticale', ' CB:true,*false'}, {'Ordina per lunghezza', ' CB:true,*false'}) if not vsVal then @@ -164,9 +165,17 @@ local function MyProcessBeams() EgtDraw() return false end - + local dOvmMid = EgtEvalNumExpr( vsVal[3]) + if not dOvmMid then + local sOut = 'Offset intermedio : ' .. vsVal[3] + EgtOutLog( sOut) + EgtOutBox( sOut, 'Lavora Travi', 'WARNING') + EgtDraw() + return false + end + -- Sistemo sezione barra con travi - local bVert = ( vsVal[3] == 'true') + local bVert = ( vsVal[4] == 'true') if bVert then if dRawW > dRawH then dRawW, dRawH = dRawH, dRawW end end @@ -206,7 +215,7 @@ local function MyProcessBeams() end -- Se richiesto, ordino le travi in senso di lunghezza crescente - local bOrd = ( vsVal[4] == 'true') + local bOrd = ( vsVal[5] == 'true') if bOrd then table.sort( vBeam, function( B1, B2) if abs( B1.Box:getDimX() - B2.Box:getDimX()) < 1 then @@ -226,7 +235,7 @@ local function MyProcessBeams() end -- Sistemo le travi nel grezzo - local bOk, sErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) + local bOk, sErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam) if not bOk then EgtOutLog( sErr) EgtOutBox( sErr, 'Lavora Travi', 'ERROR') diff --git a/Version.lua b/Version.lua index 4c03815..7aeadf8 100644 --- a/Version.lua +++ b/Version.lua @@ -1,6 +1,6 @@ --- Version.lua by Egaltech s.r.l. 2024/01/08 +-- Version.lua by Egaltech s.r.l. 2024/01/24 -- Gestione della versione di Beam NAME = 'Beam' -VERSION = '2.5l3' -MIN_EXE = '2.5l3' +VERSION = '2.6a1' +MIN_EXE = '2.6a1' From 4ba4ddb6985e5d8c4cedd90f5036584127e1082f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 24 Jan 2024 14:37:58 +0100 Subject: [PATCH 6/6] - Le lavorazioni possono essere ora ordinate per dimensioni utensile (Longest, Shortest, Biggest, Smallest). Al momento implementato solo per FindSawing. - 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. --- LuaLibs/MachiningLib.lua | 104 +++++++++++++++++---------------------- LuaLibs/ProcessSplit.lua | 27 +++++++--- 2 files changed, 65 insertions(+), 66 deletions(-) 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