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/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 43eec69..b63ce3d 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/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. -- Tabella per definizione modulo local MachiningLib = {} @@ -104,112 +107,192 @@ 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 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( 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() - local dLenTh = 72 - if EgtTdbGetCurrToolThLength then dLenTh = EgtTdbGetCurrToolThLength() end - local dFreeLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) - 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} +function VerifyDrill( Machining, dDiam, dDepth, 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( 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() - 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} +function VerifyDrillPocket( Machining, dDiam, dDepth, 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( 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) - 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} +function VerifyMill( Machining, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, 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( dMaxDiam, dDepth, dMaxTotLen, bH2) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() - local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - 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} +function VerifyPocket( Machining, dMaxDiam, dDepth, dMaxTotLen, 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 VerifyTool( MachiningType, sType, Params, bH2) +function VerifyChainSaw( Machining, dDepth, CSimmEncumberance, bH2) + -- riduco il massimo materiale dell'ingombro asse C. Se non richiesto, arriverà un valore di CSimmEncumberance nullo + 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 + +--------------------------------------------------------------------- +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 + -- leggo le lavorazioni disponibili 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 + local validMachinings = {} + 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 + 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 + 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.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) + Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam() + Machining.Tool.ToolHolderLength = EgtTdbGetCurrToolThLength() or 72 + end + end + end + end + -- 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 + 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 + + -- 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 + end --------------------------------------------------------------------- @@ -229,7 +312,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 +339,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 @@ -290,9 +374,9 @@ 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( 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 +495,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..9b65429 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -17,6 +17,9 @@ -- 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). +-- 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 = {} @@ -162,9 +165,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, bExtendStartEnd) -- Recupero i dati dell'utensile - local sSawing = ML.FindSawing( 'Sawing') local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 @@ -199,14 +201,20 @@ local function MakeSplitByChainSaw( nSurfId, nFaceUse, dDepth, sNotes, dOffs) 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) @@ -247,9 +255,9 @@ 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_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 @@ -260,11 +268,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 @@ -343,7 +351,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) @@ -355,7 +363,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') + 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 @@ -365,19 +376,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 +403,32 @@ 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) + -- 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 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 @@ -513,7 +517,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) @@ -638,7 +642,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 @@ -689,7 +694,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'