DataWindow :

- sistemata lettura per file jwd generati dal programma
- eliminata scrittura e salvataggio file ( fatti solo da programma).
This commit is contained in:
SaraP
2025-05-12 14:42:33 +02:00
parent 708f0454ba
commit bca16579ea
4 changed files with 253 additions and 827 deletions
+232 -202
View File
@@ -27,225 +27,248 @@ local WinCreate = require( 'WinCreate')
_G.package.loaded.JSON = nil
local JSON = require( 'JSON')
-- funzioni
local function ConvertCurveToTableEntity( nCurveId)
-- verifico il tipo di entita'
local nBaseOutlineType = EgtGetType( nCurveId)
if nBaseOutlineType == GDB_TY.CRV_LINE then
local ptStart = EgtSP( nCurveId)
local ptEnd = EgtEP( nCurveId)
return { [JWD_CRV_TYPE] = nBaseOutlineType, [JWD_POINT_START] = ptStart, [JWD_POINT_END] = ptEnd}
elseif nBaseOutlineType == GDB_TY.CRV_ARC then
local ptStart = EgtSP( nCurveId)
local ptEnd = EgtEP( nCurveId)
local ptMid = EgtMP( nCurveId)
return { [JWD_CRV_TYPE] = nBaseOutlineType, [JWD_POINT_START] = ptStart, [JWD_POINT_END] = ptEnd, [JWD_POINT_MID] = ptMid}
elseif nBaseOutlineType == GDB_TY.CRV_COMPO then
-- local ptStart = EgtSP( nCurveId)
-- local ptEnd = EgtEP( nCurveId)
-- local ptMid = EgtMP( nCurveId)
-- return { Type = nBaseOutlineType, ptStart = ptStart, ptEnd = ptEnd, ptMid = ptMid}
---------------------------------------------------------------------
local function GetJoints( tJoints)
local vJoints = {}
for i = 1, #tJoints do
if tJoints[i][JWD_JOINT_TYPE] == 'FULL_H' then
vJoints[i] = WIN_JNT.FULL_H
elseif tJoints[i][JWD_JOINT_TYPE] == 'FULL_V' then
vJoints[i] = WIN_JNT.FULL_V
elseif tJoints[i][JWD_JOINT_TYPE] == 'ANGLED' then
vJoints[i] = WIN_JNT.ANGLED
end
end
return vJoints
end
-- funzione ricorsiva che legge le aree e ne riporta i dati in tabella
local function ConvertAreaToTable( nAreaId)
local AreaTable = {}
local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i')
AreaTable[JWD_AREA_TYPE] = nAreaType
if nAreaType == WIN_AREATYPES.NULL then
-- non faccio nulla
elseif nAreaType == WIN_AREATYPES.FRAME then
-- recupero outline del frame
local nBaseOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE, 'i')
local JointTable = {}
-- recupero tipo giunzioni
local nJointBL = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_BL, 'i')
local nJointBR = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_BR, 'i')
local nJointTL = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_TL, 'i')
local nJointTR = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_TR, 'i')
JointTable[JWD_JOINT_BL] = nJointBL
JointTable[JWD_JOINT_BR] = nJointBR
JointTable[JWD_JOINT_TL] = nJointTL
JointTable[JWD_JOINT_TR] = nJointTR
local OutlineTable = {}
-- recupero contorno
local nBaseOutlineId = EgtGetFirstInGroup( nBaseOutlineLayerId)
local nBaseOutlineIndex = 1
while nBaseOutlineId do
local Entity = ConvertCurveToTableEntity( nBaseOutlineId)
table.insert( OutlineTable, Entity)
nBaseOutlineIndex = nBaseOutlineIndex + 1
nBaseOutlineId = EgtGetNext( nBaseOutlineId)
end
AreaTable[JWD_JOINT] = JointTable
AreaTable[JWD_OUTLINE] = OutlineTable
-- verifico se c'e' BottomRail
local nBottomRailId = EgtGetInfo( nBaseOutlineLayerId, WIN_BOTTOMRAIL, 'i')
if nBottomRailId then
AreaTable[JWD_BOTTOM_RAIL] = 1
end
elseif nAreaType == WIN_AREATYPES.SASH then
local nBaseOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
local JointTable = {}
-- recupero tipo giunzioni
local nJointBL = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_BL, 'i')
local nJointBR = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_BR, 'i')
local nJointTL = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_TL, 'i')
local nJointTR = EgtGetInfo( nBaseOutlineLayerId, WIN_JOINT_TR, 'i')
JointTable[JWD_JOINT_BL] = nJointBL
JointTable[JWD_JOINT_BR] = nJointBR
JointTable[JWD_JOINT_TL] = nJointTL
JointTable[JWD_JOINT_TR] = nJointTR
AreaTable[JWD_JOINT] = JointTable
local nSashType = EgtGetInfo( nAreaId, WIN_SASHTYPE, 'i')
if nSashType then
AreaTable[JWD_SASH_TYPE] = nSashType
end
elseif nAreaType == WIN_AREATYPES.FILL then
local nFillType = EgtGetInfo( nAreaId, WIN_FILLTYPE, 'i')
AreaTable[JWD_FILL_TYPE] = nFillType
---------------------------------------------------------------------
local function GetFrameShape( sShape)
if sShape == 'RECTANGLE' then
return WIN_FRAME_TYPES.RECT
elseif sShape == 'RIGHTCHAMFER' or sShape == 'LEFTCHAMFER' then
return WIN_FRAME_TYPES.CHAMFER_SIDE
elseif sShape == 'DOUBLECHAMFER' then
return WIN_FRAME_TYPES.CHAMFER
elseif sShape == 'ARC_FULL' then
return WIN_FRAME_TYPES.ROUND_ARC
elseif sShape == 'ARC' then
return WIN_FRAME_TYPES.SEGMENTAL_ARC
elseif sShape == 'DOUBLEARC' then
return WIN_FRAME_TYPES.POINTED_ARC
elseif sShape == 'TRIANGLE' then
return WIN_FRAME_TYPES.TRG
end
end
elseif nAreaType == WIN_AREATYPES.SPLIT then
---------------------------------------------------------------------
local function GetOpeningType( sOpeningType)
if sOpeningType == 'NULL' then
return WIN_OPENING_TYPES.NULL
elseif sOpeningType == 'TURNONLY_LEFT' then
return WIN_OPENING_TYPES.TURNONLY_LEFT
elseif sOpeningType == 'TURNONLY_RIGHT' then
return WIN_OPENING_TYPES.TURNONLY_RIGHT
elseif sOpeningType == 'TILTTURN_LEFT' then
return WIN_OPENING_TYPES.TILTTURN_LEFT
elseif sOpeningType == 'TILTTURN_RIGHT' then
return WIN_OPENING_TYPES.TILTTURN_RIGHT
elseif sOpeningType == 'TILTONLY_TOP' then
return WIN_OPENING_TYPES.TILTONLY_TOP
elseif sOpeningType == 'TILTONLY_BOTTOM' then
return WIN_OPENING_TYPES.TILTONLY_BOTTOM
elseif sOpeningType == 'PIVOT' then
return WIN_OPENING_TYPES.PIVOT
elseif sOpeningType == 'FIXED' then
return WIN_OPENING_TYPES.FIXED
elseif sOpeningType == 'COPLANARSLIDE_LEFT' then
return WIN_OPENING_TYPES.COPLANARSLIDE_LEFT
elseif sOpeningType == 'COPLANARSLIDE_RIGHT' then
return WIN_OPENING_TYPES.COPLANARSLIDE_RIGHT
elseif sOpeningType == 'LIFTSLIDE_LEFT' then
return WIN_OPENING_TYPES.LIFTSLIDE_LEFT
elseif sOpeningType == 'LIFTSLIDE_RIGHT' then
return WIN_OPENING_TYPES.LIFTSLIDE_RIGHT
end
end
---------------------------------------------------------------------
-- funzione che ricava la tipologia dell'anta in base al tipo di apertura e alla struttura
local function GetSashTypes( tSashes, vOpeningTypes)
-- alzante scorrevole
local bSlideWindow = ( vOpeningTypes[1] == WIN_OPENING_TYPES.FIXED or vOpeningTypes[1] == WIN_OPENING_TYPES.COPLANARSLIDE_RIGHT or vOpeningTypes[1] == WIN_OPENING_TYPES.LIFTSLIDE_RIGHT)
if bSlideWindow then
if #tSashes == 2 then
if vOpeningTypes[1] == WIN_OPENING_TYPES.FIXED then
return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE}
elseif vOpeningTypes[2] == WIN_OPENING_TYPES.FIXED then
return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED}
else
-- TODO individuare parametro per disinguerle
return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK}
end
else
if vOpeningTypes[1] == WIN_OPENING_TYPES.FIXED then
return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED}
elseif vOpeningTypes[2] == WIN_OPENING_TYPES.FIXED then
return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE}
else
return { WIN_SASHTYPES.SLIDE_MOVABLE_BACK, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK}
end
end
end
-- casi standard
if #tSashes == 2 then
if tSashes[1][JWD_HAS_HANDLE] then
return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE}
else
return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE}
end
end
-- verifico se c'e' Split
local nSplitLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_BASESPLIT)
if nSplitLayerId then
local SplitTable = {}
local nSplitId = EgtGetFirstInGroup( nSplitLayerId)
local Entity = ConvertCurveToTableEntity( nSplitId)
table.insert( SplitTable, Entity)
AreaTable[JWD_SPLIT] = SplitTable
end
-- ciclo sulle aree contenute
local nChildAreaId = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*')
local nChildIndex = 1
while nChildAreaId do
local ChildTable = ConvertAreaToTable( nChildAreaId)
local AreaName = JWD_AREA .. nChildIndex
AreaTable[AreaName] = ChildTable
nChildIndex = nChildIndex + 1
nChildAreaId = EgtGetNextName( nChildAreaId, WIN_AREA .. '*')
end
return AreaTable
end
-- funzione che converte una curva descritta in tabella in una geometria
local function ConvertCurveTableToEntity( nDrawFrameLayerId, CurrCurve)
if CurrCurve[JWD_CRV_TYPE] == GDB_TY.CRV_LINE then
EgtLine( nDrawFrameLayerId, Point3d(CurrCurve[JWD_POINT_START]), Point3d(CurrCurve[JWD_POINT_END]))
elseif CurrCurve[JWD_CRV_TYPE] == GDB_TY.CRV_ARC then
EgtArc3P( nDrawFrameLayerId, Point3d(CurrCurve[JWD_POINT_START]), Point3d(CurrCurve[JWD_POINT_MID]), Point3d(CurrCurve[JWD_POINT_END]))
elseif CurrCurve[JWD_CRV_TYPE] == GDB_TY.CRV_COMPO then
-- local ptStart = EgtSP( nBaseOutlineId)
-- local ptEnd = EgtEP( nBaseOutlineId)
-- local ptMid = EgtMP( nBaseOutlineId)
-- local Entity = { Type = nBaseOutlineType, ptStart = ptStart, ptEnd = ptEnd, ptMid = ptMid}
end
end
-- funzione ricorsiva che legge le aree in tabella e crea le geometrie
local function ConvertTableToGeometry( AreaTable, nAreaId)
if AreaTable[JWD_AREA_TYPE] == WIN_AREATYPES.NULL then
elseif AreaTable[JWD_AREA_TYPE] == WIN_AREATYPES.FRAME then
-- creo gruppo e layer per contorno
local nDrawFramePartId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nDrawFramePartId, 'DrawFrame')
local nDrawFrameLayerId = EgtGroup( nDrawFramePartId)
for nIndex = 1, #AreaTable[JWD_OUTLINE] do
local CurrCurve = AreaTable[JWD_OUTLINE][nIndex]
ConvertCurveTableToEntity( nDrawFrameLayerId, CurrCurve)
elseif #tSashes == 3 then
if tSashes[1][JWD_HAS_HANDLE] then
return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT}
elseif tSashes[2][JWD_HAS_HANDLE] then
if vOpeningTypes[2] == WIN_OPENING_TYPES.TURNONLY_LEFT or vOpeningTypes[2] == WIN_OPENING_TYPES.TILTTURN_LEFT then
return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE}
else
return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT}
end
else
return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE}
end
local nFrameBottomId = EgtGetFirstInGroup(nDrawFrameLayerId)
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtGetNext(nFrameBottomId)
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtGetNext(nFrameRightId)
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtGetNext(nFrameTopId)
EgtSetName( nFrameLeftId, WIN_LEFT)
-- creo frame
nAreaId = WinCreate.CreateGenFrame( {nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId}, {AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL]})
-- elimino contorno frame
EgtErase( nDrawFramePartId)
-- se BottomRail
if AreaTable[JWD_BOTTOM_RAIL] and AreaTable[JWD_BOTTOM_RAIL] == 1 then
WinCreate.AddBottomRail( nAreaId)
end
elseif AreaTable[JWD_AREA_TYPE] == WIN_AREATYPES.SASH then
nAreaId = WinCreate.AddSash( nAreaId, {AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL]}, AreaTable[JWD_SASH_TYPE])
elseif AreaTable[JWD_AREA_TYPE] == WIN_AREATYPES.FILL then
WinCreate.AddFill( nAreaId, AreaTable[JWD_FILL_TYPE])
elseif AreaTable[JWD_AREA_TYPE] == WIN_AREATYPES.SPLIT then
end
-- verifico se c'e' Split
if AreaTable[JWD_SPLIT] then
-- creo gruppo e layer per Split
local nDrawFramePartId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nDrawFramePartId, 'DrawFrame')
local nDrawFrameLayerId = EgtGroup( nDrawFramePartId)
ConvertCurveTableToEntity( nDrawFrameLayerId, AreaTable[JWD_SPLIT][1])
local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId), AreaTable["SplitType"])
-- local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId))
EgtErase(nDrawFramePartId)
ConvertTableToGeometry( AreaTable[JWD_AREA .. 1], nArea1Id)
ConvertTableToGeometry( AreaTable[JWD_AREA .. 2], nArea2Id)
else
-- ciclo sulle sotto aree
local nChildIndex = 1
while AreaTable[JWD_AREA ..nChildIndex] do
ConvertTableToGeometry( AreaTable[JWD_AREA ..nChildIndex], nAreaId)
nChildIndex = nChildIndex + 1
if tSashes[2][JWD_HAS_HANDLE] then
return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT}
else
return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT}
end
end
end
-- funzione che crea le tabelle gerarchiche dalla struttura geometrica
function WinManageProject.CreateTableFromGeom( nFrameId)
-- creo la tabella
local WinTable = {}
-- riporto la path del profilo
local nProfileId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE)
local sProfilePath = EgtGetInfo( nProfileId, WIN_PROFILEPATH)
WinTable[JWD_PROFILE_PATH] = sProfilePath
-- leggo aree
local FrameTable = ConvertAreaToTable( nFrameId)
local AreaName = JWD_AREA .. 1
WinTable[AreaName] = FrameTable
return WinTable
end
-- funzione che crea la struttura geometrica dalle tabelle gerarchiche
function WinManageProject.CreateGeomFromTable( WinTable)
-- importo profilo
if not WinCreate.ImportProfile( WinTable[JWD_PROFILE_PATH]) then
return false
end
-- creo aree
ConvertTableToGeometry( WinTable[JWD_AREA .. 1], GDB_ID.ROOT)
return true
end
-- funzione che dato un progetto gerarchico lo scrive in json su un file
function WinManageProject.WriteToFile( nFrameId, sFilePath)
local sFilePath = EgtChangePathExtension( sFilePath, JWD_EXT)
local WinTable = WinManageProject.CreateTableFromGeom( nFrameId)
local sData = JSON:encode_pretty(WinTable)
local DestFh = io.open( sFilePath, 'w+')
if not DestFh then
EgtOutBox( 'Error opening ' .. sFilePath, 'WriteToFile', 'ERROR')
---------------------------------------------------------------------
-- funzione ricorsiva che legge le aree in tabella e crea le geometrie
local function ConvertTableToGeometry( AreaTable, nParentId)
if not AreaTable then
return
end
DestFh:write( sData)
DestFh:close()
-- TELAIO
if AreaTable[JWD_AREA_TYPE] == 'FRAME' then
-- recupero i dati del telaio ( forma, giunzioni, dimensioni)
local nType = GetFrameShape( AreaTable[JWD_FRAME_SHAPE])
local vJoints = GetJoints( AreaTable[JWD_JOINTS])
local vDim = {}
local tDimensions = AreaTable[JWD_DIMENSION_LIST]
for i = 1, #tDimensions do
vDim[i] = tDimensions[i][JWD_VALUE]
end
-- creo il telaio
local nAreaId = WinCreate.CreateFrame( nType, vJoints, vDim[1], vDim[2], vDim[3])
-- verifico presenza bottomrail
if AreaTable[JWD_BOTTOMRAIL] then
WinCreate.AddBottomRail( nAreaId, AreaTable[JWD_BOTTOMRAIL_QTY])
end
-- analizzo sottoaree
if AreaTable[JWD_AREA_LIST] then
ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][1], nAreaId)
end
-- ANTA
elseif AreaTable[JWD_AREA_TYPE] == 'SASH' then
-- recupero dati
local tSashes = AreaTable[JWD_SASH_LIST]
local vJoints = GetJoints( AreaTable[JWD_JOINTS])
local nBottomRailNbr = 0
if AreaTable[JWD_BOTTOMRAIL] then
nBottomRailNbr = AreaTable[JWD_BOTTOMRAIL_QTY]
end
-- anta singola
if #tSashes == 1 then
local nAreaId = WinCreate.AddSash( nParentId, vJoints, WIN_SASHTYPES.NULL, GetOpeningType( tSashes[1][JWD_OPENING_TYPE]))
-- aggiungo ferramenta sull'anta
WinCreate.AddHardware( nAreaId, AreaTable[JWD_HARDWARE])
-- bottomrail
WinCreate.AddBottomRail( nAreaId, nBottomRailNbr)
-- analizzo sottaree
ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][1], nAreaId)
-- ante multiple
else
-- aggiungo la ferramenta sull'area parent
WinCreate.AddHardware( nParentId, AreaTable[JWD_HARDWARE])
-- recupero dati delle ante
local vDimensions = {}
local vOpeningTypes = {}
for i = 1, #tSashes do
vDimensions[i] = tSashes[i][JWD_DIMENSION] / 100
vOpeningTypes[i] = GetOpeningType( tSashes[i][JWD_OPENING_TYPE])
end
table.remove( vDimensions)
local vSashTypes = GetSashTypes( tSashes, vOpeningTypes)
-- aggiungo gli split
local vSplitAreas = WinCreate.AddSplits( nParentId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.PERCENTAGE, vDimensions, 1, WIN_SPLITTYPES.FRENCH)
-- aggiungo le ante
for i = 1, #vSplitAreas do
local nAreaId = WinCreate.AddSash( vSplitAreas[i], vJoints, vSashTypes[i], vOpeningTypes[i])
-- bottomrail
WinCreate.AddBottomRail( nAreaId, nBottomRailNbr)
-- analizzo sottaree
ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][i], nAreaId)
end
end
-- FILL
elseif AreaTable[JWD_AREA_TYPE] == 'FILL' then
local nFillType = EgtIf( AreaTable[JWD_FILL_TYPE] == 'GLASS', WIN_FILLTYPES.GLASS, WIN_FILLTYPES.WOOD)
WinCreate.AddFill( nParentId, nFillType)
-- SPLIT
elseif AreaTable[JWD_AREA_TYPE] == 'SPLIT' then
local nSplitDir = EgtIf( AreaTable[JWD_SPLIT_TYPE] == 'VERTICAL', WIN_SPLITORIENTATION.VERTICAL, WIN_SPLITORIENTATION.HORIZONTAL)
local vDimensions = {}
local vSplitDimensions = AreaTable[JWD_SPLIT_POS]
for i = 1, #vSplitDimensions - 1 do
vDimensions[i] = vSplitDimensions[i][JWD_DIMENSION] / 100
end
local vSplitAreas = WinCreate.AddSplits( nParentId, nSplitDir, WIN_MEASURE.PERCENTAGE, vDimensions, 1)
for i = 1, #vSplitAreas do
ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][i], vSplitAreas[i])
end
-- NULL
elseif AreaTable[JWD_AREA_TYPE] == 'SPLITTED' then
if AreaTable[JWD_AREA_LIST] then
ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][1], nParentId)
end
end
end
---------------------------------------------------------------------
-- funzione che dato un file in json ne crea il progetto gerarchico
function WinManageProject.ReadFromFile( sFilePath)
function WinManageProject.ReadFromFile( sFilePath, sProfileDir)
-- leggo il file
local SouFh = io.open( sFilePath, "rb")
if not SouFh then
EgtOutBox( 'Error opening ' .. sFilePath, 'ReadFromFile', 'ERROR')
@@ -254,9 +277,16 @@ function WinManageProject.ReadFromFile( sFilePath)
local content = SouFh:read( "*all")
SouFh:close()
local tData = JSON:decode( content)
if not WinManageProject.CreateGeomFromTable( tData) then
-- importo il profilo
local sProfilePath = sProfileDir .. '\\' .. tData[JWD_PROFILE_PATH] .. '.nge'
if not WinCreate.ImportProfile( sProfilePath) then
return false
end
-- creo le aree
ConvertTableToGeometry( tData[JWD_AREA_LIST][1], GDB_ID.ROOT)
return true
end