From 2f329961ba9bd6b433a13a21917e4efe093e2843 Mon Sep 17 00:00:00 2001 From: DarioS Date: Tue, 17 Jan 2023 11:44:36 +0100 Subject: [PATCH] DataBeam : - correzione al Nesting 1D. --- NestProcess.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NestProcess.lua b/NestProcess.lua index ace4f83..0ea2932 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -1,7 +1,8 @@ --- BeamNestProcess.lua by Egaltech s.r.l. 2021/06/14 +-- BeamNestProcess.lua by Egaltech s.r.l. 2023/01/15 -- Gestione nesting automatico travi --- 2022/10/05 Piccole modifiche per far funzionare correttamente i compilati --- 2022/10/06 Corretto bug che moltiplicava i pezzi se erano presenti più grezzi della stessa sezione +-- 2022/10/05 Piccole modifiche per far funzionare correttamente i compilati. +-- 2022/10/06 Corretto bug che moltiplicava i pezzi se erano presenti più grezzi della stessa sezione. +-- 2023/01/15 Piccole correzioni. -- Intestazioni require( 'EgtBase') @@ -162,20 +163,21 @@ local nWarnCnt = 0 local Raws = {} -- creo tabella dei grezzi for nIndex, nLen in pairs( LEN) do - table.insert(Raws, {LenToFill = nLen, StartGap = NEST.STARTOFFSET, MidGap = NEST.OFFSET, EndGap = 0, SortType = -1}) + Raws[tonumber(nIndex)] = {LenToFill = nLen, StartGap = NEST.STARTOFFSET, MidGap = NEST.OFFSET, EndGap = 0, SortType = -1} end for nIndex, nQty in pairs( QTY) do Raws[tonumber(nIndex)].Count = nQty end - --- Pezzi -local Parts = {} - -- cerco il grezzo con la lunghezza maggiore, epurata dello start gap local maxRawLenToFillNoStartGap = 0 for RawIndex = 1, #Raws do - maxRawLenToFillNoStartGap = max( maxRawLenToFillNoStartGap, Raws[RawIndex].LenToFill - Raws[RawIndex].StartGap) + if Raws[RawIndex].Count > 0 then + maxRawLenToFillNoStartGap = max( maxRawLenToFillNoStartGap, Raws[RawIndex].LenToFill - Raws[RawIndex].StartGap) + end end + +-- Pezzi +local Parts = {} -- ciclo su pezzi per aggiungerli al nesting local dTotLen = 0 for nPartId, nCount in pairs( PART) do @@ -295,7 +297,7 @@ local function NestSolutionByIndex( Index) if TempRaws[RawIndex].Count > 0 then Results[RawIndex] = ExecMaximumFilling( TempRaws[RawIndex], PartsToNest) else - Results[RawIndex] = { FillRatio = 0.001, LenToFill = 1000} + Results[RawIndex] = { FillRatio = 0.001, LenToFill = 1000, DiffParts = 0} end end -- verifico quale e' quella con meno scarto @@ -304,7 +306,7 @@ local function NestSolutionByIndex( Index) for ResultIndex = 1, #Results do if Results[ResultIndex] then local dWaste = (1 - Results[ResultIndex].FillRatio) * TempRaws[ResultIndex].LenToFill - if dWaste < dMinWaste then + if Results[ResultIndex].DiffParts > 0 and dWaste < dMinWaste then dMinWaste = dWaste nMinWasteRawIndex = ResultIndex end