From 2978b800ae6b2f8a07f9e81fdefeee4ffa7be39d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 27 Jul 2026 20:01:09 +0200 Subject: [PATCH] Window 3.1g3 : - semplificazioni e sistemazioni varie per esecuzione manuale. --- ManCreateWindow.lua | 22 +++++++++++--- ManPrepMachGroups.lua | 18 ++++++------ ManProcOneMachGroup.lua | 64 ++++++++++++++++++++++++++--------------- Version.lua | 2 +- Window.ini | 4 +-- 5 files changed, 70 insertions(+), 40 deletions(-) diff --git a/ManCreateWindow.lua b/ManCreateWindow.lua index dc3f5fe..cbd4ee1 100644 --- a/ManCreateWindow.lua +++ b/ManCreateWindow.lua @@ -28,12 +28,25 @@ local sOpenFilePath = '' -- verifico se lanciato file in batch per test if WINDOW and WINDOW.FILE then sOpenFilePath = WINDOW.FILE +-- oppure in interattivo else - -- altrimenti apro dialogo di scelta file - local sOpenDirPath = 'C:\\EgtData\\EgtWindowMaker\\Projects\\*.jwd' - sOpenFilePath = EgtFileDialog( true, sOpenDirPath, "Window Project Files (*.jwd)|*.jwd||") - if not sOpenFilePath then + -- se voglio aprire ultima finestra generata + if EgtGetKeyPressed( GEN_VK.SHIFT) then + local sLastWinPath = EgtGetStringFromIni( 'Window', 'LastWin', '', EgtGetIniFile()) + if not EgtExistsFile( sLastWinPath) then + EgtOutBox( 'Non esiste Finestra corrente', 'Crea Serramento - Window', 'INFO', 'OK') + return + end + EgtOpenFile( sLastWinPath) + EgtZoom( SCE_ZM.ALL) return + -- altrimenti apro dialogo di scelta file JWD + else + local sOpenDirPath = 'C:\\EgtData\\EgtWindowMaker\\Projects\\*.jwd' + sOpenFilePath = EgtFileDialog( true, sOpenDirPath, "Window Project Files (*.jwd)|*.jwd||") + if not sOpenFilePath then + return + end end end @@ -66,4 +79,5 @@ if WINDOW and WINDOW.TEST == 1 then else EgtSaveFile() EgtZoom( SCE_ZM.ALL) + EgtWriteStringToIni( 'Window', 'LastWin', sFilePath, EgtGetIniFile()) end diff --git a/ManPrepMachGroups.lua b/ManPrepMachGroups.lua index d6d5962..9598e4f 100644 --- a/ManPrepMachGroups.lua +++ b/ManPrepMachGroups.lua @@ -7,6 +7,13 @@ _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', 'Prepara Macchinate - Window', 'INFO', 'OK') + return +end + -- rimuovo eventuali macchinate già presenti local nMachId = EgtGetFirstMachGroup() while nMachId do @@ -24,18 +31,9 @@ local bOk, sErr = pcall( dofile, EgtGetSourceDir() .. 'CAMAuto\\CreateMachGroups -- se errore, lo segnalo ed esco if not bOk then - EgtOutBox( sErr, 'Prepara Macchinate', 'OK', 'ERROR') + EgtOutBox( sErr, 'Prepara Macchinate - Window', 'OK', 'ERROR') return end --- esporto ciascuna macchinata in un proprio file -local sFilePath = EgtGetCurrFilePath() -local sFileDir, _, _ = EgtSplitPath( sFilePath) -nMachId = EgtGetFirstMachGroup() -while nMachId do - EgtSaveMachGroupToFile( nMachId, sFileDir .. EgtGetMachGroupName( nMachId) .. '.bwe') - nMachId = EgtGetNextMachGroup( nMachId) -end - -- salvo il file del serramento EgtSaveFile() diff --git a/ManProcOneMachGroup.lua b/ManProcOneMachGroup.lua index c018d28..ffa19c0 100644 --- a/ManProcOneMachGroup.lua +++ b/ManProcOneMachGroup.lua @@ -7,44 +7,62 @@ _ENV = EgtProtectGlobal() EgtEnableDebug( false) --- scelta della macchinata da aprire -local sOpenDirPath = EgtGetStringFromIni( 'Window', 'LastJwdDir', 'C:\\EgtData\\EgtWindowMaker\\Projects', EgtGetIniFile()) -if EgtEndsWith( sOpenDirPath, '\\') then - sOpenDirPath = sOpenDirPath .. '*.bwe' -else - sOpenDirPath = sOpenDirPath .. '\\*.bwe' -end -sOpenFilePath = EgtFileDialog( true, sOpenDirPath, "Window MachGroup Files (*.bwe)|*.bwe||") -if not sOpenFilePath then +-- 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 -local sDir = EgtSplitPath( sOpenFilePath) -EgtWriteStringToIni( 'Window', 'LastJwdDir', sDir, EgtGetIniFile()) --- eventuale copia dell'originale -local sOrigFile = EgtChangePathExtension( sOpenFilePath, '.omgr') -if not EgtExistsFile( sOrigFile) then - EgtCopyFile( sOpenFilePath, sOrigFile) +-- 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 --- cancello eventuali vecchi file con lo stesso nome -local vFiles = EgtFindAllFiles( EgtChangePathExtension( sOpenFilePath, '*')) +-- 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 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] - if string.upper( sFileToErase) ~= string.upper( sOrigFile) then - EgtEraseFile( sFileToErase) - end + EgtEraseFile( sFileToErase) end --- copio l'originale come nuovo file di partenza -EgtCopyFile( sOrigFile, sOpenFilePath) +-- 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 = sOpenFilePath, + FILE = sMGrpPath, MACHINE = 'Saomad-Just3500', FLAG = 1} diff --git a/Version.lua b/Version.lua index ef2dd5a..7598936 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Window NAME = 'Window' -VERSION = '3.1g2' +VERSION = '3.1g3' MIN_EXE = '3.1g1' diff --git a/Window.ini b/Window.ini index 9b48b5a..4c60bad 100644 --- a/Window.ini +++ b/Window.ini @@ -3,7 +3,7 @@ JwdEnable=1 BaseDir=C:\EgtData\Window ProfileDir=C:\EgtData\EgtWindowMaker\Profiles -LastJwdDir= -Button1=ManCreateWindow.lua,Images\CreateWin.png,Crea Serramento +LastWin= +Button1=ManCreateWindow.lua,Images\CreateWin.png,Crea Finestra - Carica Ultima Fatta (Shift) Button2=ManPrepMachGroups.lua,Images\ManPrepMachGrps.png,Prepara Macchinate Button3=ManProcOneMachGroup.lua,Images\ManProcOneMachGrp.png,Lavora Una Macchinata