Merge remote-tracking branch 'origin/develop' into CORESTRATEGY_SlotByChainSaw

This commit is contained in:
luca.mazzoleni
2024-06-20 17:09:11 +02:00
5 changed files with 321 additions and 241 deletions
+32 -29
View File
@@ -67,11 +67,13 @@ end
local BeamExec = require( 'BeamExec')
-- Variabili globali
PARTS = {}
-- Carico i dati globali
local BeamData = require( 'BeamData')
-- Variabili di modulo
local vBeam = {}
local dRawW
local dRawH
@@ -86,47 +88,47 @@ local function MyProcessInputData()
local nPartId = EgtGetParent( EgtGetParent( nId or GDB_ID.NULL) or GDB_ID.NULL)
if nPartId then
local bFound = false
for i = 1, #vBeam do
if vBeam[i].id == nPartId then
for i = 1, #PARTS do
if PARTS[i].id == nPartId then
bFound = true
break
end
end
if not bFound then
table.insert( vBeam, { nInd = #vBeam + 1, id = nPartId, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
table.insert( PARTS, { nInd = #PARTS + 1, id = nPartId, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
end
end
nId = EgtGetNextSelectedObj()
end
if #vBeam == 0 then
if #PARTS == 0 then
EgtOutBox( 'Non sono state selezionate travi', 'Lavora Travi', 'ERROR')
return false
else
local sOut = ''
for i = 1, #vBeam do
sOut = sOut .. vBeam[i].sName .. ', '
for i = 1, #PARTS do
sOut = sOut .. PARTS[i].sName .. ', '
end
sOut = sOut:sub( 1, -3)
EgtOutLog( 'Travi selezionate : ' .. sOut, 1)
end
-- Ne recupero e verifico le dimensioni
for i = 1, #vBeam do
local Ls = EgtGetFirstNameInGroup( vBeam[i].id, 'Box')
for i = 1, #PARTS do
local Ls = EgtGetFirstNameInGroup( PARTS[i].id, 'Box')
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
if not b3Solid then
EgtOutBox( 'Box non definito per la trave ' .. vBeam[i].sName, 'Lavora Travi', 'ERROR')
EgtOutBox( 'Box non definito per la trave ' .. PARTS[i].sName, 'Lavora Travi', 'ERROR')
return false
else
vBeam[i].b3Box = b3Solid
PARTS[i].b3Box = b3Solid
end
end
dRawW = vBeam[1].b3Box:getDimY()
dRawH = vBeam[1].b3Box:getDimZ()
dRawW = PARTS[1].b3Box:getDimY()
dRawH = PARTS[1].b3Box:getDimZ()
local vBeamErr = {}
for i = 2, #vBeam do
local dDimW = vBeam[i].b3Box:getDimY()
local dDimH = vBeam[i].b3Box:getDimZ()
for i = 2, #PARTS do
local dDimW = PARTS[i].b3Box:getDimY()
local dDimH = PARTS[i].b3Box:getDimZ()
if ( abs( dDimW - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 10 * GEO.EPS_SMALL) and
( abs( dDimH - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 10 * GEO.EPS_SMALL) then
table.insert( vBeamErr, i)
@@ -135,9 +137,9 @@ local function MyProcessInputData()
if #vBeamErr > 0 then
local sOut = 'Rimosse travi con sezioni diverse dalla prima :\n'
for i = #vBeamErr, 1, -1 do
sOut = sOut .. vBeam[vBeamErr[i]].sName .. '\n'
EgtDeselectPartObjs( vBeam[vBeamErr[i]].id)
table.remove( vBeam, vBeamErr[i])
sOut = sOut .. PARTS[vBeamErr[i]].sName .. '\n'
EgtDeselectPartObjs( PARTS[vBeamErr[i]].id)
table.remove( PARTS, vBeamErr[i])
end
EgtOutLog( sOut, 1)
EgtOutBox( sOut, 'Lavora Travi', 'INFO')
@@ -172,17 +174,18 @@ local function MyProcessBeams()
-- Lunghezza totale delle travi
local dTotLen = 0
for i = 1, #vBeam - 1 do
dTotLen = dTotLen + vBeam[i].b3Box:getDimX()
for i = 1, #PARTS - 1 do
dTotLen = dTotLen + PARTS[i].b3Box:getDimX()
end
dTotLen = dTotLen + max( vBeam[#vBeam].b3Box:getDimX(), BeamData.dMinRaw)
local dAddLen = BeamData.OVM_HEAD + ( #vBeam - 1) * BeamData.OVM_MID
dTotLen = dTotLen + max( PARTS[#PARTS].b3Box:getDimX(), BeamData.dMinRaw)
local dAddLen = BeamData.OVM_HEAD + ( #PARTS - 1) * BeamData.OVM_MID
EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BeamData.dMinRaw + BeamData.OVM_MID, 1), 1)
-- Richiedo lunghezza del grezzo, sovramateriale di testa, forzatura verticale e ordinamento automatico secondo la lunghezza
local vsVal = EgtDialogBox( 'Lavora Travi' .. ' (Ltot='..EgtNumToString( dTotLen + dAddLen + 0.5, 0)..
', Lmax='..EgtNumToString( BeamData.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BeamData.dMinRaw + BeamData.OVM_MID, 0)..')',
{'Lunghezza grezzo', EgtNumToString( BeamData.STD_RAW, 0)},
--{'Lunghezza grezzo', EgtNumToString( BeamData.STD_RAW, 0)}, -- TODO RIPRISTINARE
{'Lunghezza grezzo', EgtNumToString( 0)},
{'Sovramateriale di testa', EgtNumToString( BeamData.OVM_HEAD, 0)},
{'Offset intermedio', EgtNumToString( BeamData.OVM_MID, 0)},
{'Forza sezione verticale', ' CB:true,*false'},
@@ -262,7 +265,7 @@ local function MyProcessBeams()
-- Se richiesto, ordino le travi in senso di lunghezza crescente
local bOrd = ( vsVal[5] == 'true')
if bOrd then
table.sort( vBeam, function( B1, B2)
table.sort( PARTS, function( B1, B2)
if abs( B1.b3Box:getDimX() - B2.b3Box:getDimX()) < 1 then
return B1.nInd < B2.nInd
else
@@ -272,15 +275,15 @@ local function MyProcessBeams()
end
do
local sOut = ''
for i = 1, #vBeam do
sOut = sOut .. vBeam[i].sName .. ', '
for i = 1, #PARTS do
sOut = sOut .. PARTS[i].sName .. ', '
end
sOut = sOut:sub( 1, -3)
EgtOutLog( 'Travi ordinate : ' .. sOut, 1)
end
-- Sistemo le travi nel grezzo
local bOk, sErr = BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam)
local bOk, sErr = BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS)
if not bOk then
EgtOutLog( sErr)
EgtOutBox( sErr, 'Lavora Travi', 'ERROR')
@@ -294,7 +297,7 @@ end
-- *** Inserimento delle lavorazioni nelle travi ***
-------------------------------------------------------------------------------------------------------------
local function MyProcessFeatures()
local bOk, Stats = BeamExec.ProcessFeatures()
local bOk, Stats = BeamExec.ProcessFeatures( PARTS)
local nErrCnt = 0
local nWarnCnt = 0
local sOutput = ''