CAMAuto :
- Raggruppate funzioni riguardati i pezzi in PartData.
This commit is contained in:
+13
-80
@@ -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
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- Process.lua by Egalware s.r.l. 2024/06/13
|
||||
-- Gestione calcolo disposizione e lavorazioni per serramenti
|
||||
-- Si opera sulla macchina corrente
|
||||
-- 2024/06/13 PRIMA VERSIONE
|
||||
-- CreateMachGroups.lua by Egalware s.r.l. 2026/02/09
|
||||
-- Creazione dei MachGroup del file già aperto
|
||||
|
||||
|
||||
-- Intestazioni
|
||||
@@ -9,12 +7,19 @@ require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( false)
|
||||
|
||||
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
-- TODO DA CANCELLARE!!!! quando verrà passato automaticamente da programma
|
||||
--local WIN = {}
|
||||
--WIN.MACHINELIST = {}
|
||||
--WIN.MACHINELIST[1] = 'Saomad-Just3500'
|
||||
--WIN.OPT_TYPE = 'WINDOW'
|
||||
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
|
||||
--Libero eventuali librerie rimaste caricate
|
||||
_G.package.loaded.WinData = nil
|
||||
_G.package.loaded.WinLib = nil
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle finestre
|
||||
if not WIN.MACHINELIST or #WIN.MACHINELIST == 0 or #WIN.MACHINELIST[1] == 0 then
|
||||
EgtOutLog( 'Errore! Macchina non impostata!')
|
||||
return
|
||||
@@ -43,6 +48,7 @@ EgtOutLog( '*** Window Process Start ***', 1)
|
||||
-- Carico le librerie
|
||||
EgtAddToPackagePath( EgtGetSourceDir() .. 'LuaLibs\\?.lua')
|
||||
local WinLib = require( 'WinLib')
|
||||
local PartData = require( 'PartData')
|
||||
|
||||
-- Carico i dati globali
|
||||
local WinData = require( 'WinData')
|
||||
@@ -54,38 +60,11 @@ GROUPS = {}
|
||||
-- Colore del grezzo
|
||||
local ColA = Color3d( 255, 165, 0, 30)
|
||||
|
||||
-- TODO DA RIMUOVERE, il parametro deve essere passato
|
||||
local WIN = {}
|
||||
--WIN.OPT_TYPE = 'PIECE'
|
||||
WIN.OPT_TYPE = 'WINDOW'
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- *** Recupero offset applicato al profilo ***
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
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
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- *** Recupero i pezzi da processare ***
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function GetInfoPieces()
|
||||
-- Recupero le travi selezionate
|
||||
-- Recupero i pezzi delle finestre
|
||||
local nId = EgtGetFirstPart()
|
||||
while nId do
|
||||
-- TODO caricare il file di costanti
|
||||
@@ -111,7 +90,7 @@ local function GetInfoPieces()
|
||||
PARTS[i].DispOffsets.Phase1 = {}
|
||||
PARTS[i].DispOffsets.Phase2 = {}
|
||||
|
||||
local bInsertedAllOffs = GetDispOffsetFromNotes( i)
|
||||
local bInsertedAllOffs = PartData.GetDispOffsetFromNotes( PARTS, i)
|
||||
|
||||
-- recupero info profili
|
||||
PARTS[i].SemiProfiles = {}
|
||||
@@ -132,6 +111,7 @@ local function GetInfoPieces()
|
||||
|
||||
-- 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
|
||||
|
||||
@@ -146,43 +126,6 @@ local function GetInfoPieces()
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Aggiunge al grezzo i sovramateriali pre-impostati
|
||||
---------------------------------------------------------------------
|
||||
local function AddOverMaterialToRaw( PiecesInMachGroup)
|
||||
for i = 1, #PiecesInMachGroup do
|
||||
|
||||
-- prima di aggiungere sovramateriale al grezzo, calcolo dimensioni del finito
|
||||
local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PiecesInMachGroup[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
PiecesInMachGroup[i].b3Part = b3Part
|
||||
PiecesInMachGroup[i].dPartLength = PiecesInMachGroup[i].b3Part:getDimX()
|
||||
PiecesInMachGroup[i].dPartWidth = PiecesInMachGroup[i].b3Part:getDimY()
|
||||
PiecesInMachGroup[i].dPartHeight = PiecesInMachGroup[i].b3Part:getDimZ()
|
||||
|
||||
-- recupero sovramateriale
|
||||
PiecesInMachGroup[i].RawOffset = {}
|
||||
-- recupero info sovramateriale
|
||||
PiecesInMachGroup[i].RawOffset.dOverMatIn = EgtGetInfo( PiecesInMachGroup[i].id, 'OVERMAT_IN', 'd') or 5
|
||||
PiecesInMachGroup[i].RawOffset.dOverMatOut = EgtGetInfo( PiecesInMachGroup[i].id, 'OVERMAT_OUT', 'd') or 5
|
||||
PiecesInMachGroup[i].RawOffset.dOverMatLeft = EgtGetInfo( PiecesInMachGroup[i].id, 'OVERMAT_LEFT', 'd') or 5
|
||||
PiecesInMachGroup[i].RawOffset.dOverMatRight = EgtGetInfo( PiecesInMachGroup[i].id, 'OVERMAT_RIGHT', 'd') or 5
|
||||
|
||||
PiecesInMachGroup[i].dRawLength = PiecesInMachGroup[i].RawOffset.dOverMatLeft + PiecesInMachGroup[i].dPartLength + PiecesInMachGroup[i].RawOffset.dOverMatRight
|
||||
PiecesInMachGroup[i].dRawWidth = PiecesInMachGroup[i].RawOffset.dOverMatOut + PiecesInMachGroup[i].dPartWidth + PiecesInMachGroup[i].RawOffset.dOverMatIn
|
||||
PiecesInMachGroup[i].dRawHeight = PiecesInMachGroup[i].dPartHeight
|
||||
|
||||
EgtModifyRawPartSize( PiecesInMachGroup[i].idRaw, PiecesInMachGroup[i].dRawLength, PiecesInMachGroup[i].dRawWidth, PiecesInMachGroup[i].dPartHeight)
|
||||
|
||||
local vtMove = Vector3d( PiecesInMachGroup[i].RawOffset.dOverMatLeft, PiecesInMachGroup[i].RawOffset.dOverMatOut, 0)
|
||||
EgtMovePartInRawPart( PiecesInMachGroup[i].id, vtMove)
|
||||
|
||||
-- TODO da controllare, se ruotato di 180° bisognerebbe prendere dOverMatIn. Lo stesso per la X
|
||||
PiecesInMachGroup[i].OffsetPartToRaw = {}
|
||||
PiecesInMachGroup[i].OffsetPartToRaw.X = PiecesInMachGroup[i].RawOffset.dOverMatLeft
|
||||
PiecesInMachGroup[i].OffsetPartToRaw.Y = PiecesInMachGroup[i].RawOffset.dOverMatOut
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Crea il grezzo che verrà messo in macchina
|
||||
---------------------------------------------------------------------
|
||||
@@ -350,7 +293,7 @@ local function CreateMachGroups()
|
||||
AlignRawsToTable( GROUPS[j])
|
||||
|
||||
-- aggiungo sovramateriale ai grezzi
|
||||
AddOverMaterialToRaw( GROUPS[j])
|
||||
PartData.AddOverMaterialToRaw( GROUPS[j])
|
||||
|
||||
-- si dispongono i pezzi sulla tavola
|
||||
local bDispOk, sErr = WinData.ExecDisposition( GROUPS[j])
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
-- PartData.lua by Egalware s.r.l. 2026/02/19
|
||||
-- Libreria globale per Serramenti
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local PartData = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
local WinData = require( 'WinData')
|
||||
|
||||
EgtOutLog( ' PartData started', 1)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- Recupero offset applicato al profilo
|
||||
function PartData.GetDispOffsetFromNotes( PARTS, 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
|
||||
function PartData.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
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Recupera le dimensioni dei pezzi
|
||||
function PartData.GetDimensionPart( PARTS)
|
||||
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
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
return PartData
|
||||
+9
-79
@@ -18,7 +18,7 @@ EgtAddToPackagePath( WIN.BASEDIR .. '\\LuaLibs\\?.lua')
|
||||
-- Imposto direttorio strategie. N.B. Le strategie dovranno essere caricate con il nome del direttorio padre
|
||||
EgtAddToPackagePath( WIN.BASEDIR .. '\\Strategies\\?.lua')
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle finestre
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
if not sMachDir then
|
||||
EgtOutBox( 'Errore nel caricamento della macchina corrente', 'Lavora Serramenti', 'ERROR')
|
||||
@@ -44,6 +44,7 @@ _G.package.loaded.FeatureData = nil
|
||||
_G.package.loaded.MachiningLib = nil
|
||||
|
||||
local WinExec = require( 'WinExec')
|
||||
local PartData = require( 'PartData')
|
||||
|
||||
-- Carico i dati globali
|
||||
local WinData = require( 'WinData')
|
||||
@@ -58,7 +59,7 @@ local ColA = Color3d( 255, 165, 0, 30)
|
||||
-- *** Recupero i pezzi da processare ***
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function MyProcessInputData()
|
||||
-- Recupero le travi selezionate
|
||||
-- Recupero i pezzi selezionati
|
||||
local nId = EgtGetFirstSelectedObj()
|
||||
while nId do
|
||||
local nPartId = EgtGetParent( EgtGetParent( nId or GDB_ID.NULL) or GDB_ID.NULL)
|
||||
@@ -76,23 +77,9 @@ local function MyProcessInputData()
|
||||
end
|
||||
nId = EgtGetNextSelectedObj()
|
||||
end
|
||||
if #PARTS == 0 then
|
||||
EgtOutBox( 'Non sono state selezionati 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
|
||||
@@ -107,26 +94,6 @@ local function GetDataConfig()
|
||||
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
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function GetDispOffsetFromInput( nPieceIndex)
|
||||
-- assegno alle stringhe i valori letti, in modo che vengano proposti quelli nel dialogo
|
||||
@@ -151,43 +118,6 @@ local function GetDispOffsetFromInput( nPieceIndex)
|
||||
return true
|
||||
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
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Crea il grezzo che verrà messo in macchina
|
||||
---------------------------------------------------------------------
|
||||
@@ -246,7 +176,7 @@ local nMachGroupId = EgtGetFirstMachGroup()
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- *** Inserimento delle travi nel grezzo ***
|
||||
-- *** Inserimento dei pezzi nel grezzo ***
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function MyProcessPieces()
|
||||
|
||||
@@ -261,7 +191,7 @@ local function MyProcessPieces()
|
||||
AlignRawsToTable( PARTS)
|
||||
|
||||
-- aggiungo sovramateriale ai grezzi
|
||||
AddOverMaterialToRaw( PARTS)
|
||||
PartData.AddOverMaterialToRaw( PARTS)
|
||||
|
||||
-- recupero offset per posizionamento
|
||||
for i = 1, #PARTS do
|
||||
@@ -269,7 +199,7 @@ local function MyProcessPieces()
|
||||
PARTS[i].DispOffsets.Phase1 = {}
|
||||
PARTS[i].DispOffsets.Phase2 = {}
|
||||
|
||||
local bInsertedAllOffs = GetDispOffsetFromNotes( i)
|
||||
local bInsertedAllOffs = PartData.GetDispOffsetFromNotes( PARTS, i)
|
||||
-- se non sono settati nelle note, li chiedo
|
||||
if not bInsertedAllOffs then
|
||||
bInsertedAllOffs = GetDispOffsetFromInput( i)
|
||||
|
||||
Reference in New Issue
Block a user