Files
egwwindowlua/Designing/WinOpenProjectFile.lua
T
2025-09-26 12:03:38 +02:00

84 lines
2.5 KiB
Lua

--
-- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT
-- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT
-- EEEE GGGG GGGG TTTT
-- EEEE GGGG TTTT
-- EEEEEEE GGGG GGGGGGG TTTT
-- EEEEEEE GGGG GGGGGGG TTTT
-- EEEE GGGG GGGG TTTT
-- EEEE GGGG GGGG TTTT
-- EEEEEEEEEE GGGGGGGGGG TTTT
-- EEEEEEEEEE GGGGGG TTTT
--
-- by Egalware s.r.l.
-- Window project software by Egalware s.r.l. 2023/05/02
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( true)
-- Imposto direttorio per librerie
local sBaseDir = EgtGetSourceDir()
EgtOutLog("BaseDir=" .. sBaseDir)
EgtAddToPackagePath( sBaseDir .. '?.lua')
EgtAddToPackagePath( sBaseDir .. 'WinLib\\' .. '?.lua')
_G.package.loaded.WinCalculate = nil
local WinCalculate = require( 'WinCalculate')
_G.package.loaded.WinManageProject = nil
local WinManageProject = require( 'WinManageProject')
local sOpenFilePath = ''
-- verifico se lanciato file in batch per test
if WINDOW and WINDOW.FILE then
sOpenFilePath = WINDOW.FILE
else
-- altrimenti apro dialogo di scelta file
local sOpenDirPath = 'c:\\EgtData\\EgtWindowMaker\\Projects'
local FilePathList = EgtFindAllFiles( sOpenDirPath .. '\\*.jwd')
local sDialogFile = 'CB:'
for FilePathIndex = 1, #FilePathList do
local sName = EgtSplitString( FilePathList[FilePathIndex], '.')
sDialogFile = sDialogFile .. sName[1] .. ','
end
local DialogRes = EgtDialogBox( 'Open Window Project', { 'Nome Progetto', sDialogFile })
if DialogRes and DialogRes[1] then
sOpenFilePath = sOpenDirPath .. '\\' .. DialogRes[1] .. '.jwd'
else
return
end
end
EgtNewFile()
EgtStartCounter()
local sProfileDir = 'C:\\EgtData\\EgtWindowMaker\\Profiles'
if not WinManageProject.ReadFromFile( sOpenFilePath, sProfileDir) then
return
end
-- imposto se calcolare i solidi o meno
WinCalculate.SetCalcSolid( true)
-- creo i pezzi
local nFrameId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_AREA .. '*')
WinCalculate.CreatePartFromArea( nFrameId)
-- WinCalculate.AddHardware( nFrameId)
-- WinCalculate.AddAccessories( nFrameId, true)
-- elimino profilo se in batch per test
if WINDOW and WINDOW.TEST and WINDOW.TEST == 1 then
local nProfileGroupId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE)
if nProfileGroupId and nProfileGroupId ~= GDB_ID.NULL then
EgtErase( nProfileGroupId)
end
end
EgtZoom( SCE_ZM.ALL)
-- riporto tempi di esecuzione
local sOut = string.format( ' ExecTime = %.2f ms', EgtStopCounter())
EgtOutLog( sOut)