c8ec5c73ad
- aggiunta gestione flip pezzi per lavorare in prima fase interno invece di esterno - aggiunta cancellazione di tutti i vecchi file risultato in modalità manuale.
100 lines
3.0 KiB
Lua
100 lines
3.0 KiB
Lua
-- ManProcOneMachGroup.lua by Egalware s.r.l. 2026/07/27
|
|
-- Creazione delle lavorazioni del MachGroup selezionato
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
_ENV = EgtProtectGlobal()
|
|
EgtEnableDebug( false)
|
|
|
|
|
|
-- Verifico che il progetto sia un serramento
|
|
local nAreaId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'Area(Frame)')
|
|
if not nAreaId then
|
|
EgtOutBox( 'Caricare il progetto di una finestra', 'Lavora Una Macchinata - Window', 'INFO', 'OK')
|
|
return
|
|
end
|
|
|
|
-- Verifico che il progetto contenga già le macchinate
|
|
if not EgtGetFirstMachGroup() then
|
|
EgtOutBox( 'Preparare le macchinate della finestra', 'Lavora Una Macchinata - Window', 'INFO', 'OK')
|
|
return
|
|
end
|
|
|
|
-- dati generali del progetto
|
|
local sWinPath = EgtGetCurrFilePath()
|
|
local sDir = EgtSplitPath( sWinPath)
|
|
|
|
-- Scelta della macchinata da lavorare
|
|
local sMGrpList
|
|
local nMGrpId = EgtGetFirstMachGroup()
|
|
while nMGrpId do
|
|
local sMGrpName = EgtGetMachGroupName( nMGrpId)
|
|
local sDone = ''
|
|
if EgtExistsFile( sDir .. sMGrpName .. '.bwe') then
|
|
sDone = ' [===]'
|
|
end
|
|
if not sMGrpList then
|
|
sMGrpList = 'CB:' .. sMGrpName .. sDone
|
|
else
|
|
sMGrpList = sMGrpList .. ',' .. sMGrpName .. sDone
|
|
end
|
|
nMGrpId = EgtGetNextMachGroup( nMGrpId)
|
|
end
|
|
local vRes = EgtDialogBox( 'Lavora Una Macchinata - Window', { 'Macchinata', sMGrpList})
|
|
if not vRes or #vRes < 1 then
|
|
return
|
|
end
|
|
local sMGrpName = EgtReplaceString( vRes[1], ' [===]', '')
|
|
|
|
-- cancello eventuali file generati dalla macchinata
|
|
local sMGrpFile = sDir .. sMGrpName .. '.bwe'
|
|
if EgtExistsFile( sMGrpFile) then
|
|
local nOrigCtx = EgtGetContext()
|
|
local nCtx = EgtCreateContext()
|
|
if nCtx and EgtOpenFile( sMGrpFile) then
|
|
local nMgId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'MachBase') or GDB_ID.NULL)
|
|
if nMgId then
|
|
local sNcName = EgtGetInfo( nMgId, 'NcName')
|
|
if sNcName then
|
|
local _, sSpecName, _ = EgtSplitPath( sNcName)
|
|
local vFiles = EgtFindAllFiles( sDir .. sSpecName .. '*.*') or {}
|
|
for i = 1, #vFiles do
|
|
local sFileToErase = sDir .. vFiles[i]
|
|
EgtEraseFile( sFileToErase)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
EgtDeleteContext( nCtx)
|
|
EgtSetContext( nOrigCtx)
|
|
end
|
|
|
|
-- cancello tutti i file del direttorio con il nome della macchinata
|
|
local vFiles = EgtFindAllFiles( sDir .. sMGrpName .. '.*') or {}
|
|
for i = 1, #vFiles do
|
|
local sFileToErase = sDir .. vFiles[i]
|
|
EgtEraseFile( sFileToErase)
|
|
end
|
|
|
|
-- salvo la macchinata scelta in un nuovo file
|
|
local sMGrpPath = sDir .. sMGrpName .. '.bwe'
|
|
EgtSaveMachGroupToFile( EgtGetMachGroupId( sMGrpName), sMGrpPath)
|
|
|
|
-- lancio
|
|
local _, sBaseDir = EgtEndsWith( EgtGetSourceDir(), '\\')
|
|
sBaseDir = sBaseDir .. '\\CAMAuto'
|
|
|
|
_G.WIN = { BASEDIR = sBaseDir,
|
|
FILE = sMGrpPath,
|
|
MACHINE = 'Saomad-Just3500',
|
|
FLAG = 1}
|
|
|
|
-- aggiungo le lavorazioni
|
|
local bOk, sErr = pcall( dofile, sBaseDir .. '\\BatchProcessWin.lua')
|
|
|
|
-- salvo il file
|
|
EgtSaveFile()
|
|
|
|
EgtSetCurrMachGroup()
|
|
EgtZoom( SCE_ZM.ALL)
|