CAMAuto :

- Raggruppate funzioni riguardati i pezzi in PartData.
This commit is contained in:
Annamaria Sassi
2026-02-20 09:55:15 +01:00
parent e623f2d789
commit ff953deaff
4 changed files with 129 additions and 231 deletions
+13 -80
View File
@@ -1,4 +1,6 @@
-- BatchProcessNew.lua by Egalware s.r.l. 2025/04/24
-- BatchProcessNew.lua by Egalware s.r.l. 2026/02/09
-- Applicazione lavorazioni, simulazione, generazione e stima
-- Intestazioni
require( 'EgtBase')
@@ -71,6 +73,7 @@ _G.package.loaded.MachiningLib = nil
local WinExec = require( 'WinExec')
local WinLib = require( 'WinLib')
local JSON = require( 'JSON')
local PartData = require( 'PartData')
-- Carico i dati globali
local WinData = require( 'WinData')
@@ -137,87 +140,16 @@ local function MyProcessInputData()
end
nId = EgtGetNext( nId)
end
if #PARTS == 0 then
EgtOutBox( 'Non ci sono pezzi', 'Lavora Pezzi', 'ERROR')
return false
else
-- recupero tutte le dimensioni necessarie
local sOut = ''
for i = 1, #PARTS do
PARTS[i].b3Raw = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'GeoRaw') or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
local idFrame = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'GeoRaw'), 'AuxFrame')
PARTS[i].frame = EgtFR( idFrame)
sOut = sOut .. PARTS[i].sName .. ', '
end
sOut = sOut:sub( 1, -3)
EgtOutLog( 'Pezzi selezionati : ' .. sOut, 1)
end
PartData.GetDimensionPart( PARTS)
EgtDeselectAll()
return true
end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromNotes( nPieceIndex)
local bAllOffsetsAreOk = false
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_2', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_2', 'd')
-- controllo se tutti gli offset siano settati
if PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ and
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ then
bAllOffsetsAreOk = true
end
return bAllOffsetsAreOk
end
---------------------------------------------------------------------
-- Crea il grezzo che verrà messo in macchina
---------------------------------------------------------------------
local function AddOverMaterialToRaw( PARTS)
for i = 1, #PARTS do
-- prima di aggiungere sovramateriale al grezzo, calcolo dimensioni del finito
local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3Part = b3Part
PARTS[i].dPartLength = PARTS[i].b3Part:getDimX()
PARTS[i].dPartWidth = PARTS[i].b3Part:getDimY()
PARTS[i].dPartHeight = PARTS[i].b3Part:getDimZ()
-- recupero sovramateriale
PARTS[i].RawOffset = {}
-- recupero info sovramateriale
PARTS[i].RawOffset.dOverMatIn = EgtGetInfo( PARTS[i].id, 'OVERMAT_IN', 'd') or 5
PARTS[i].RawOffset.dOverMatOut = EgtGetInfo( PARTS[i].id, 'OVERMAT_OUT', 'd') or 5
PARTS[i].RawOffset.dOverMatLeft = EgtGetInfo( PARTS[i].id, 'OVERMAT_LEFT', 'd') or 5
PARTS[i].RawOffset.dOverMatRight = EgtGetInfo( PARTS[i].id, 'OVERMAT_RIGHT', 'd') or 5
PARTS[i].dRawLength = PARTS[i].RawOffset.dOverMatLeft + PARTS[i].dPartLength + PARTS[i].RawOffset.dOverMatRight
PARTS[i].dRawWidth = PARTS[i].RawOffset.dOverMatOut + PARTS[i].dPartWidth + PARTS[i].RawOffset.dOverMatIn
PARTS[i].dRawHeight = PARTS[i].dPartHeight
EgtModifyRawPartSize( PARTS[i].idRaw, PARTS[i].dRawLength, PARTS[i].dRawWidth, PARTS[i].dPartHeight)
local vtMove = Vector3d( PARTS[i].RawOffset.dOverMatLeft, PARTS[i].RawOffset.dOverMatOut, 0)
EgtMovePartInRawPart( PARTS[i].id, vtMove)
-- TODO da controllare, se ruotato di 180° bisognerebbe prendere dOverMatIn. Lo stesso per la X
PARTS[i].OffsetPartToRaw = {}
PARTS[i].OffsetPartToRaw.X = PARTS[i].RawOffset.dOverMatLeft
PARTS[i].OffsetPartToRaw.Y = PARTS[i].RawOffset.dOverMatOut
end
end
-------------------------------------------------------------------------------------------------------------
-- *** Inserimento delle travi nel grezzo ***
-- *** Inserimento dei pezzi nel grezzo ***
-------------------------------------------------------------------------------------------------------------
local function MyProcessPieces()
@@ -230,7 +162,7 @@ local function MyProcessPieces()
end
-- aggiungo sovramateriale ai grezzi
AddOverMaterialToRaw( PARTS)
PartData.AddOverMaterialToRaw( PARTS)
-- recupero offset per posizionamento
for i = 1, #PARTS do
@@ -238,9 +170,10 @@ local function MyProcessPieces()
PARTS[i].DispOffsets.Phase1 = {}
PARTS[i].DispOffsets.Phase2 = {}
local bInsertedAllOffs = GetDispOffsetFromNotes( i)
local bInsertedAllOffs = PartData.GetDispOffsetFromNotes( PARTS, i)
-- se non sono stati inseriti o c'è stato un errore esco subito
if not bInsertedAllOffs then
EgtOutBox( 'Errore offset non trovati', 'BatchProcessWin', 'ERROR', 'OK')
return false
end
end
@@ -251,7 +184,7 @@ local function MyProcessPieces()
if not sErr then
sErr = 'Errore non gestito in WinData.AdjustDisposition'
end
EgtOutBox( sErr, 'ProcessWin', 'ERROR', 'OK')
EgtOutBox( sErr, 'BatchProcessWin', 'ERROR', 'OK')
return false
end
@@ -269,7 +202,7 @@ end
-------------------------------------------------------------------------------------------------------------
-- WIN.FLAG :
-- 0 = generazione e stima, esegue solo un aggiornamento (eventuale) delle lavorazioni
-- 1 = da processare completamente, applicazione lavorazioni, simulazione, generazioen e stima
-- 1 = da processare completamente, applicazione lavorazioni, simulazione, generazione e stima
-- 2 = da processare in preverifica, applicazione lavorazioni e stima
-- In generale va completamente riprocessato