Files
egwwindowlua/Designing/WinOpenProjectFile.lua
T
SaraP a85a50d7c1 DataWindow :
- modificato nome file WinConst in CAMAuto per evitare conflitto con Designing
- sistemato caricamento librerie.
2026-01-14 09:28:10 +01:00

97 lines
2.9 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( false)
-- Imposto direttorio per librerie
local sBaseDir = EgtGetSourceDir()
EgtOutLog("BaseDir=" .. sBaseDir)
EgtAddToPackagePath( sBaseDir .. '?.lua')
EgtAddToPackagePath( sBaseDir .. 'WinLib\\' .. '?.lua')
_G.package.loaded.WinConst = nil
_G.package.loaded.WinJWDConst = nil
_G.package.loaded.WinCreate = nil
_G.package.loaded.WinCalculate = nil
_G.package.loaded.WinManageProject = nil
_G.package.loaded.JSON = nil
_G.package.loaded.xml2lua = nil
_G.package.loaded.xml2lua_tree = nil
require( 'WinConst')
local WinManageProject = require( 'WinManageProject')
local WinCalculate = require( 'WinCalculate')
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
local sFilePath = EgtChangePathExtension( sOpenFilePath, 'nge')
EgtSetCurrFilePath( sFilePath)
-- imposto se calcolare i solidi o meno
WinCalculate.SetCalcSolid( true)
--WinCalculate.SetCalcPreview( true)
-- creo i pezzi
local nFrameId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_AREA .. '*')
WinCalculate.CreatePartFromArea( nFrameId)
WinCalculate.AddHardware( nFrameId, true, false, false, false)
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)