PySimultan 0.1.54__py3-none-any.whl → 0.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- PySimultan-0.2.dist-info/LICENSE.txt +17 -0
- PySimultan-0.2.dist-info/METADATA +36 -0
- PySimultan-0.2.dist-info/RECORD +82 -0
- {PySimultan-0.1.54.dist-info → PySimultan-0.2.dist-info}/WHEEL +1 -1
- PySimultan-0.2.dist-info/top_level.txt +1 -0
- {PySimultan → PySimultan2}/__init__.py +11 -6
- PySimultan2/config.py +52 -0
- PySimultan2/data_model.py +713 -0
- PySimultan2/default_types.py +507 -0
- PySimultan2/files.py +371 -0
- PySimultan2/geometry/__init__.py +4 -0
- PySimultan2/geometry/geometry_base.py +654 -0
- PySimultan2/geometry/utils.py +181 -0
- PySimultan2/multi_values.py +277 -0
- PySimultan2/object_mapper.py +200 -0
- PySimultan2/resources/AssimpNet.dll +0 -0
- PySimultan2/resources/AvalonDock.dll +0 -0
- PySimultan2/resources/BruTile.dll +0 -0
- PySimultan2/resources/ClosedXML.dll +0 -0
- PySimultan2/resources/ComponentBuilder.dll +0 -0
- PySimultan/resources/ComponentBuilder.exe.config → PySimultan2/resources/ComponentBuilder.dll.config +6 -2
- PySimultan2/resources/ComponentBuilder.runtimeconfig.json +18 -0
- {PySimultan → PySimultan2}/resources/ComponentBuilder.xml +11877 -6754
- PySimultan2/resources/ControlzEx.dll +0 -0
- PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
- PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
- PySimultan2/resources/ExcelNumberFormat.dll +0 -0
- PySimultan2/resources/Fluent.dll +0 -0
- PySimultan2/resources/GeometryViewer.dll +0 -0
- {PySimultan → PySimultan2}/resources/GeometryViewer.xml +2201 -1155
- PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
- PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
- PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
- PySimultan2/resources/HelixToolkit.dll +0 -0
- PySimultan2/resources/MathNet.Numerics.dll +0 -0
- PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
- PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
- PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
- PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
- PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
- PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
- PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
- PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
- PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
- PySimultan2/resources/Newtonsoft.Json.dll +0 -0
- PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
- PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
- PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +15 -0
- PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
- {PySimultan → PySimultan2}/resources/SIMULTAN.Lang.xml +5282 -3252
- PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
- {PySimultan → PySimultan2}/resources/SIMULTAN.Plugins.xml +110 -0
- PySimultan2/resources/SIMULTAN.UI.dll +0 -0
- {PySimultan → PySimultan2}/resources/SIMULTAN.UI.xml +10483 -4937
- PySimultan2/resources/SIMULTAN.dll +0 -0
- PySimultan2/resources/SIMULTAN.xml +34122 -0
- PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
- PySimultan2/resources/SharpDX.DXGI.dll +0 -0
- PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
- PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
- PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
- {PySimultan → PySimultan2}/resources/SharpDX.Mathematics.dll +0 -0
- PySimultan2/resources/SharpDX.dll +0 -0
- {PySimultan → PySimultan2}/resources/SitePlanner.dll +0 -0
- {PySimultan → PySimultan2}/resources/SitePlanner.xml +959 -1110
- PySimultan2/resources/Sprache.dll +0 -0
- PySimultan2/resources/System.Data.OleDb.dll +0 -0
- PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
- PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
- PySimultan2/resources/assimp.dll +0 -0
- {PySimultan → PySimultan2}/resources/defaultsettings.xml +0 -0
- PySimultan2/simultan_object.py +366 -0
- PySimultan2/taxonomy_maps.py +169 -0
- PySimultan2/utils.py +1383 -0
- PySimultan/config.py +0 -57
- PySimultan/data_model.py +0 -376
- PySimultan/default_types.py +0 -1771
- PySimultan/geo_default_types.py +0 -763
- PySimultan/geometry.py +0 -309
- PySimultan/resources/AssimpNet.dll +0 -0
- PySimultan/resources/AssimpNet.xml +0 -12074
- PySimultan/resources/BruTile.dll +0 -0
- PySimultan/resources/BruTile.xml +0 -1845
- PySimultan/resources/ControlzEx.dll +0 -0
- PySimultan/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
- PySimultan/resources/DXFImportExport.dll +0 -0
- PySimultan/resources/DotSpatial.Projections.xml +0 -5879
- PySimultan/resources/EXCELImportExport.dll +0 -0
- PySimultan/resources/Fluent.dll +0 -0
- PySimultan/resources/Fluent.xml +0 -9103
- PySimultan/resources/GeoJSON.Net.dll +0 -0
- PySimultan/resources/GeometryViewer.Data.dll +0 -0
- PySimultan/resources/GeometryViewer.Data.xml +0 -4443
- PySimultan/resources/GeometryViewer.Shared.dll +0 -0
- PySimultan/resources/GeometryViewer.Shared.xml +0 -588
- PySimultan/resources/GeometryViewer.dll +0 -0
- PySimultan/resources/HelixToolkit.Wpf.SharpDX.dll +0 -0
- PySimultan/resources/HelixToolkit.Wpf.SharpDX.xml +0 -43219
- PySimultan/resources/HelixToolkit.Wpf.dll +0 -0
- PySimultan/resources/HelixToolkit.Wpf.xml +0 -22363
- PySimultan/resources/HelixToolkit.dll +0 -0
- PySimultan/resources/HelixToolkit.xml +0 -144
- PySimultan/resources/ImportLog_SMART_CAMPUS_TU_WIEN_BIBLIOTHEK_20210305_ZONENMODELL_23_11_2021-06_54_54.txt +0 -1
- PySimultan/resources/LibGit2Sharp.dll +0 -0
- PySimultan/resources/LibGit2Sharp.dll.config +0 -4
- PySimultan/resources/LibGit2Sharp.xml +0 -13770
- PySimultan/resources/MathNet.Numerics.dll +0 -0
- PySimultan/resources/MathNet.Numerics.xml +0 -57152
- PySimultan/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
- PySimultan/resources/Microsoft.WindowsAPICodePack.Shell.xml +0 -25496
- PySimultan/resources/Microsoft.WindowsAPICodePack.dll +0 -0
- PySimultan/resources/Microsoft.WindowsAPICodePack.xml +0 -2934
- PySimultan/resources/Newtonsoft.Json.dll +0 -0
- PySimultan/resources/Newtonsoft.Json.xml +0 -11305
- PySimultan/resources/ParameterStructure.dll +0 -0
- PySimultan/resources/ParameterStructure.xml +0 -10750
- PySimultan/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
- PySimultan/resources/SIMULTAN.DataExchange.dll +0 -0
- PySimultan/resources/SIMULTAN.Lang.dll +0 -0
- PySimultan/resources/SIMULTAN.Legacy.dll +0 -0
- PySimultan/resources/SIMULTAN.Legacy.xml +0 -254
- PySimultan/resources/SIMULTAN.Plugins.dll +0 -0
- PySimultan/resources/SIMULTAN.Project.dll +0 -0
- PySimultan/resources/SIMULTAN.Project.dll.config +0 -11
- PySimultan/resources/SIMULTAN.UI.dll +0 -0
- PySimultan/resources/SIMULTAN.Util.dll +0 -0
- PySimultan/resources/SIMULTAN.Util.xml +0 -3430
- PySimultan/resources/SharpDX.D3DCompiler.dll +0 -0
- PySimultan/resources/SharpDX.D3DCompiler.xml +0 -5897
- PySimultan/resources/SharpDX.DXGI.dll +0 -0
- PySimultan/resources/SharpDX.DXGI.xml +0 -8737
- PySimultan/resources/SharpDX.Direct2D1.dll +0 -0
- PySimultan/resources/SharpDX.Direct2D1.xml +0 -46691
- PySimultan/resources/SharpDX.Direct3D11.dll +0 -0
- PySimultan/resources/SharpDX.Direct3D11.xml +0 -31826
- PySimultan/resources/SharpDX.Direct3D9.dll +0 -0
- PySimultan/resources/SharpDX.Direct3D9.xml +0 -36489
- PySimultan/resources/SharpDX.Mathematics.xml +0 -16449
- PySimultan/resources/SharpDX.dll +0 -0
- PySimultan/resources/Sprache.dll +0 -0
- PySimultan/resources/Sprache.xml +0 -1199
- PySimultan/resources/System.Net.Http.Formatting.dll +0 -0
- PySimultan/resources/System.Net.Http.Formatting.xml +0 -2094
- PySimultan/resources/System.Windows.Interactivity.dll +0 -0
- PySimultan/resources/TalkGit.dll +0 -0
- PySimultan/resources/TalkGit.dll.config +0 -11
- PySimultan/resources/WebServiceConnector.dll +0 -0
- PySimultan/resources/WebServiceConnector.dll.config +0 -11
- PySimultan/resources/XAMLMarkupExtensions.dll +0 -0
- PySimultan/resources/XAMLMarkupExtensions.xml +0 -862
- PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.Aero.dll +0 -0
- PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.Metro.dll +0 -0
- PySimultan/resources/Xceed.Wpf.AvalonDock.Themes.VS2010.dll +0 -0
- PySimultan/resources/Xceed.Wpf.AvalonDock.dll +0 -0
- PySimultan/resources/Xceed.Wpf.Toolkit.dll +0 -0
- PySimultan/resources/assimp.dll +0 -0
- PySimultan/resources/schema.yaml +0 -13
- PySimultan/resources/simultan_exception_07_10_2021-08_34_24.txt +0 -17
- PySimultan/resources/simultan_exception_07_10_2021-10_13_31.txt +0 -17
- PySimultan/resources/simultan_exception_11_10_2021-19_45_42.txt +0 -17
- PySimultan/resources/simultan_exception_22_11_2021-16_41_52.txt +0 -14
- PySimultan/resources/simultan_exception_22_11_2021-17_37_40.txt +0 -14
- PySimultan/simultan_geometry_utils.py +0 -81
- PySimultan/simultan_utils.py +0 -165
- PySimultan/slots.py +0 -51
- PySimultan/template_tools.py +0 -631
- PySimultan/utils.py +0 -298
- PySimultan-0.1.54.dist-info/LICENSE +0 -674
- PySimultan-0.1.54.dist-info/LICENSE.txt +0 -674
- PySimultan-0.1.54.dist-info/METADATA +0 -690
- PySimultan-0.1.54.dist-info/RECORD +0 -119
- PySimultan-0.1.54.dist-info/entry_points.txt +0 -3
- PySimultan-0.1.54.dist-info/top_level.txt +0 -1
- PySimultan-0.1.54.dist-info/zip-safe +0 -1
- {PySimultan → PySimultan2}/resources/DotSpatial.Projections.dll +0 -0
- {PySimultan → PySimultan2}/resources/GeometryViewer.dll.config +0 -0
- {PySimultan → PySimultan2}/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
- {PySimultan → PySimultan2}/resources/SitePlanner.dll.config +0 -0
- {PySimultan → PySimultan2}/resources/Sprache.Calc.dll +0 -0
- {PySimultan → PySimultan2}/resources/__init__.py +0 -0
- {PySimultan → PySimultan2}/resources/setup.bat +0 -0
PySimultan/config.py
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import clr
|
3
|
-
import colorlog
|
4
|
-
try:
|
5
|
-
import importlib.resources as pkg_resources
|
6
|
-
except ImportError:
|
7
|
-
# Try backported to PY<37 importlib_resources.
|
8
|
-
import importlib_resources as pkg_resources
|
9
|
-
|
10
|
-
from ruamel.yaml import YAML, yaml_object, add_representer
|
11
|
-
from . import resources
|
12
|
-
|
13
|
-
logger = colorlog.getLogger('PySimultan')
|
14
|
-
|
15
|
-
# import SIMULTAN DLLs
|
16
|
-
|
17
|
-
clr.AddReference('System.Collections')
|
18
|
-
|
19
|
-
# check if environment variable is set:
|
20
|
-
try:
|
21
|
-
dll_path = os.environ['SIMULTAN_SDK_DIR']
|
22
|
-
clr.AddReference(os.path.join(dll_path, 'SIMULTAN.Project.dll'))
|
23
|
-
clr.AddReference(os.path.join(dll_path, 'ParameterStructure.dll'))
|
24
|
-
clr.AddReference(os.path.join(dll_path, 'SIMULTAN.UI.dll'))
|
25
|
-
clr.AddReference(os.path.join(dll_path, 'GeometryViewer.dll'))
|
26
|
-
clr.AddReference(os.path.join(dll_path, 'GeometryViewer.Data.dll'))
|
27
|
-
clr.AddReference(os.path.join(dll_path, 'SIMULTAN.DataExchange.dll'))
|
28
|
-
|
29
|
-
except KeyError as e:
|
30
|
-
logger.info(f'SIMULTAN Environment variable not set. Loading package DLLs...')
|
31
|
-
with pkg_resources.path(resources, 'SIMULTAN.Project.dll') as r_path:
|
32
|
-
clr.AddReference(str(r_path))
|
33
|
-
with pkg_resources.path(resources, 'ParameterStructure.dll') as r_path:
|
34
|
-
clr.AddReference(str(r_path))
|
35
|
-
with pkg_resources.path(resources, 'SIMULTAN.UI.dll') as r_path:
|
36
|
-
clr.AddReference(str(r_path))
|
37
|
-
with pkg_resources.path(resources, 'GeometryViewer.dll') as r_path:
|
38
|
-
clr.AddReference(str(r_path))
|
39
|
-
with pkg_resources.path(resources, 'GeometryViewer.Data.dll') as r_path:
|
40
|
-
clr.AddReference(str(r_path))
|
41
|
-
with pkg_resources.path(resources, 'SIMULTAN.DataExchange.dll') as r_path:
|
42
|
-
clr.AddReference(str(r_path))
|
43
|
-
|
44
|
-
|
45
|
-
def represent_none(self, _):
|
46
|
-
return self.represent_scalar('tag:yaml.org,2002:null', '')
|
47
|
-
|
48
|
-
|
49
|
-
add_representer(type(None), represent_none)
|
50
|
-
yaml = YAML()
|
51
|
-
yaml.default_flow_style = None
|
52
|
-
yaml.preserve_quotes = True
|
53
|
-
yaml.allow_unicode = True
|
54
|
-
|
55
|
-
continue_on_error = True
|
56
|
-
|
57
|
-
cs_axis_up = 2 # define which axis is in up/down direction; 0: x-axis; 1: y-axis; 2: z-axis; In SIMULTAN the y-axis is the up/down axis
|
PySimultan/data_model.py
DELETED
@@ -1,376 +0,0 @@
|
|
1
|
-
import sys
|
2
|
-
import time
|
3
|
-
|
4
|
-
import colorlog
|
5
|
-
import atexit
|
6
|
-
from uuid import uuid4
|
7
|
-
from functools import lru_cache
|
8
|
-
from weakref import WeakSet
|
9
|
-
|
10
|
-
from SIMULTAN.Project.Services import IAuthenticationService
|
11
|
-
from ParameterStructure import Projects
|
12
|
-
from SIMULTAN.Project.Project import ExtendedProjectData
|
13
|
-
from SIMULTAN.Project.ProjectLoaders import ZipProjectIO
|
14
|
-
from SIMULTAN.UI.Services import ServicesProvider
|
15
|
-
|
16
|
-
# from .SIMULTAN.DataExchange import ComponentGeometryExchange
|
17
|
-
# from .ParameterStructure.Component import ComponentManagerType
|
18
|
-
from ParameterStructure.Users import *
|
19
|
-
from GeometryViewer import TemporaryGeometryViewerInstance
|
20
|
-
from GeometryViewer.Service import GeometryViewerService
|
21
|
-
from GeometryViewer.Model import *
|
22
|
-
from GeometryViewer.IO import SimGeoIO
|
23
|
-
from GeometryViewer import IGeometryViewerService
|
24
|
-
from System.Security import SecureString
|
25
|
-
from System.IO import FileInfo
|
26
|
-
from System import ArgumentOutOfRangeException
|
27
|
-
from ParameterStructure.Components import SimComponent, SimSlot, SimSlotBase, SimChildComponentEntry, ComponentUtils
|
28
|
-
from ParameterStructure.Algorithms.Components import ComponentManagement
|
29
|
-
# from .ParameterStructure.Algorithms.Components import ComponentMapping
|
30
|
-
# from .ParameterStructure.Parameters import SimParameter
|
31
|
-
from ParameterStructure.Values import SimMultiValueBigTable
|
32
|
-
# from .ParameterStructure.Assets import ContainedResourceFileEntry
|
33
|
-
|
34
|
-
|
35
|
-
ProjectData = Projects.ProjectData
|
36
|
-
|
37
|
-
# from .utils import *
|
38
|
-
# from .geo_default_types import *
|
39
|
-
|
40
|
-
# from .geometry import GeometryModel
|
41
|
-
|
42
|
-
|
43
|
-
logger = colorlog.getLogger('PySimultan')
|
44
|
-
|
45
|
-
|
46
|
-
class IAuthenticationServiceNew(IAuthenticationService):
|
47
|
-
__namespace__ = "authenticate_namespace"
|
48
|
-
|
49
|
-
user_name = None
|
50
|
-
password = None
|
51
|
-
|
52
|
-
def Authenticate(self, user_manager, project_file):
|
53
|
-
# user_name = 'admin'
|
54
|
-
# password = 'admin'
|
55
|
-
|
56
|
-
sec_str = SecureString()
|
57
|
-
for char in self.password:
|
58
|
-
sec_str.AppendChar(char)
|
59
|
-
|
60
|
-
user = user_manager.Authenticate(self.user_name, sec_str)
|
61
|
-
|
62
|
-
user_manager.CurrentUser = user.Item1
|
63
|
-
user_manager.EncryptionKey = user.Item2
|
64
|
-
|
65
|
-
return user.Item1
|
66
|
-
|
67
|
-
|
68
|
-
data_models = WeakSet()
|
69
|
-
|
70
|
-
|
71
|
-
class DataModel:
|
72
|
-
|
73
|
-
def __new__(cls, *args, **kwargs):
|
74
|
-
|
75
|
-
instance = super().__new__(cls)
|
76
|
-
|
77
|
-
try:
|
78
|
-
data_models.add(instance)
|
79
|
-
except Exception as e:
|
80
|
-
logger.error(f'Error adding instance {instance} to data_models: {e}')
|
81
|
-
return instance
|
82
|
-
|
83
|
-
def __init__(self, *args, **kwargs):
|
84
|
-
"""
|
85
|
-
|
86
|
-
:param args:
|
87
|
-
:param kwargs:
|
88
|
-
"""
|
89
|
-
self.user_name = kwargs.get('user_name', 'admin')
|
90
|
-
self.password = kwargs.get('password', 'admin')
|
91
|
-
|
92
|
-
atexit.register(self.cleanup)
|
93
|
-
|
94
|
-
self.id = uuid4()
|
95
|
-
self.data = None
|
96
|
-
self._project_data_manager = None
|
97
|
-
self._user = None
|
98
|
-
self._project = None
|
99
|
-
self._zip_loader = None
|
100
|
-
|
101
|
-
self.project_path = kwargs.get('project_path', None)
|
102
|
-
|
103
|
-
self.service_provider = ServicesProvider()
|
104
|
-
|
105
|
-
self.i_aut_service = IAuthenticationServiceNew
|
106
|
-
self.i_aut_service.user_name = self.user_name
|
107
|
-
self.i_aut_service.password = self.password
|
108
|
-
|
109
|
-
# self.i_aut_service = create_IAuthenticationService(self.user_name, self.password)
|
110
|
-
self.service_provider.AddService[IAuthenticationService](self.i_aut_service())
|
111
|
-
|
112
|
-
self.serv = GeometryViewerService([], self.service_provider)
|
113
|
-
|
114
|
-
self.service_provider.AddService[IGeometryViewerService](self.serv)
|
115
|
-
|
116
|
-
self.exch = self.project.AllProjectDataManagers.GeometryCommunicator
|
117
|
-
self.exch.ModelStore = self.serv
|
118
|
-
self.inst = TemporaryGeometryViewerInstance(self.exch)
|
119
|
-
self.resources = {}
|
120
|
-
self.models_dict = {}
|
121
|
-
|
122
|
-
if self.project_data_manager.AssetManager.Resources.__len__() > 0:
|
123
|
-
for resource in self.project_data_manager.AssetManager.Resources:
|
124
|
-
if resource is None:
|
125
|
-
continue
|
126
|
-
self.resources[resource.Key] = resource
|
127
|
-
self.models_dict[resource.Key] = None
|
128
|
-
current_full_path = resource.CurrentFullPath
|
129
|
-
if current_full_path == '?':
|
130
|
-
continue
|
131
|
-
|
132
|
-
file_info = FileInfo(resource.CurrentFullPath)
|
133
|
-
|
134
|
-
if file_info.Extension == '.simgeo':
|
135
|
-
model = SimGeoIO.Load(file_info, self.inst, self.serv)
|
136
|
-
self.models_dict[resource.Key] = model
|
137
|
-
try:
|
138
|
-
self.serv.AddGeometryModel(model)
|
139
|
-
except ArgumentOutOfRangeException as e:
|
140
|
-
logger.warning(f'Error while loading Model: {model} from {model.File}: {e}. Trying reload...')
|
141
|
-
model = SimGeoIO.Load(file_info, self.inst, self.serv)
|
142
|
-
self.models_dict[resource.Key] = model
|
143
|
-
self.serv.AddGeometryModel(model)
|
144
|
-
|
145
|
-
self.ValueFields = self.project_data_manager.ValueManager.Items
|
146
|
-
self.import_data_model()
|
147
|
-
|
148
|
-
@property
|
149
|
-
def models(self):
|
150
|
-
return self.models_dict.values()
|
151
|
-
|
152
|
-
@property
|
153
|
-
def project_data_manager(self):
|
154
|
-
if (self._project_data_manager) is None and (self.user is not None):
|
155
|
-
self._project_data_manager = ExtendedProjectData()
|
156
|
-
return self._project_data_manager
|
157
|
-
|
158
|
-
@project_data_manager.setter
|
159
|
-
def project_data_manager(self, value):
|
160
|
-
self._project_data_manager = value
|
161
|
-
|
162
|
-
@property
|
163
|
-
def user(self):
|
164
|
-
if self._user is None:
|
165
|
-
self._user = SimUserRole.ADMINISTRATOR
|
166
|
-
return self._user
|
167
|
-
|
168
|
-
@user.setter
|
169
|
-
def user(self, value):
|
170
|
-
if value != self._user:
|
171
|
-
self.project_data_manager = None
|
172
|
-
self._project = None
|
173
|
-
self._user = value
|
174
|
-
|
175
|
-
@property
|
176
|
-
def project(self):
|
177
|
-
if (self._project is None) and (self.project_path is not None) and (self.project_data_manager is not None):
|
178
|
-
logger.debug('loading project')
|
179
|
-
self.project = ZipProjectIO.Load(FileInfo(self.project_path), self.project_data_manager, self.service_provider)
|
180
|
-
exit_code = ZipProjectIO.AuthenticateUserAfterLoading(self.project, self.project_data_manager, bytearray('ThWmZq4t6w9z$C&F', 'ascii'))
|
181
|
-
if not exit_code:
|
182
|
-
logger.error('Could not open project. Wrong user or password! Exiting program...')
|
183
|
-
ZipProjectIO.OpenAfterAuthentication(self.project, self.project_data_manager)
|
184
|
-
logger.debug('project loaded successfull')
|
185
|
-
return self._project
|
186
|
-
|
187
|
-
@project.setter
|
188
|
-
def project(self, value):
|
189
|
-
self._project = value
|
190
|
-
|
191
|
-
def get_typed_data(self, template_parser, create_all=False):
|
192
|
-
|
193
|
-
template_parser._create_all = create_all
|
194
|
-
template_parser.current_data_model = self
|
195
|
-
|
196
|
-
for cls in template_parser.template_classes.values():
|
197
|
-
if create_all:
|
198
|
-
cls._create_all = True
|
199
|
-
else:
|
200
|
-
cls._create_all = False
|
201
|
-
|
202
|
-
data = []
|
203
|
-
|
204
|
-
for item in self.data.Items:
|
205
|
-
logger.info(f'Creating python object for: {item.Name}')
|
206
|
-
new_comp = template_parser.create_python_object(item)
|
207
|
-
|
208
|
-
try:
|
209
|
-
if create_all:
|
210
|
-
try:
|
211
|
-
_ = new_comp.contained_components
|
212
|
-
except AttributeError:
|
213
|
-
pass
|
214
|
-
|
215
|
-
try:
|
216
|
-
_ = new_comp.contained_parameters
|
217
|
-
except AttributeError:
|
218
|
-
pass
|
219
|
-
|
220
|
-
try:
|
221
|
-
_ = new_comp.referenced_components
|
222
|
-
except AttributeError:
|
223
|
-
pass
|
224
|
-
|
225
|
-
except Exception as e:
|
226
|
-
logger.error(f'Could create all sub-components for {new_comp.name}:\n{e}')
|
227
|
-
data.append(new_comp)
|
228
|
-
|
229
|
-
logger.info('\n\nType info: \n----------------------------------')
|
230
|
-
logger.info(f'created {data.__len__()} top level instances')
|
231
|
-
for cls in set(template_parser.template_classes.values()):
|
232
|
-
if hasattr(cls, 'cls_instances'):
|
233
|
-
logger.info(f'created {cls.cls_instances.__len__()} instances of type {cls.__name__}')
|
234
|
-
return data
|
235
|
-
|
236
|
-
def import_data_model(self):
|
237
|
-
self.data = self.project_data_manager.Components
|
238
|
-
self.data.set_EnableAsyncUpdates(False)
|
239
|
-
|
240
|
-
return self.data
|
241
|
-
|
242
|
-
@lru_cache(maxsize=None)
|
243
|
-
def get_geo_instance(self, file_id, type, id):
|
244
|
-
geo_model = self.models[file_id]
|
245
|
-
objects = getattr(geo_model.Geometry, type)
|
246
|
-
|
247
|
-
return next((x for x in objects.Items if x.Id == id), None)
|
248
|
-
|
249
|
-
def add_component(self, component: SimComponent):
|
250
|
-
self.data.Add(component)
|
251
|
-
|
252
|
-
def save(self):
|
253
|
-
ZipProjectIO.Save(self.project, False)
|
254
|
-
|
255
|
-
def cleanup(self):
|
256
|
-
"""
|
257
|
-
Close and cleanup project
|
258
|
-
"""
|
259
|
-
logger.info('closing project...')
|
260
|
-
try:
|
261
|
-
if self._project is not None:
|
262
|
-
if self._project.IsOpened:
|
263
|
-
ZipProjectIO.Close(self._project, False, True)
|
264
|
-
if self._project.IsLoaded:
|
265
|
-
ZipProjectIO.Unload(self._project)
|
266
|
-
except Exception as e:
|
267
|
-
pass
|
268
|
-
|
269
|
-
# def create_new_component(self):
|
270
|
-
#
|
271
|
-
# ref_comp = self.data.Items[0]
|
272
|
-
#
|
273
|
-
# new_comp = SimComponent()
|
274
|
-
# new_comp.Name = 'Test'
|
275
|
-
#
|
276
|
-
# new_param = SimParameter('test_param', 'Unicorn', 15.268)
|
277
|
-
# new_comp.Parameters.Add(new_param)
|
278
|
-
#
|
279
|
-
# sub_new_comp = SimComponent()
|
280
|
-
# sub_new_comp.CurrentSlot = SimSlotBase(ComponentUtils.COMP_SLOT_AREAS)
|
281
|
-
# sub_new_comp.Name = 'SubTest'
|
282
|
-
#
|
283
|
-
# entry = SimChildComponentEntry(SimSlot(SimSlotBase(ComponentUtils.COMP_SLOT_AREAS), '15'),
|
284
|
-
# sub_new_comp)
|
285
|
-
# new_comp.Components.Add(entry)
|
286
|
-
#
|
287
|
-
# slot = SimSlot(ref_comp.CurrentSlot, '11')
|
288
|
-
# ComponentManagement.AddReferencedComponentSlot(new_comp, slot, self.user)
|
289
|
-
# ComponentManagement.AddReferencedComponent(new_comp, slot, ref_comp, self.user)
|
290
|
-
#
|
291
|
-
# self.add_component(new_comp)
|
292
|
-
# self.save()
|
293
|
-
#
|
294
|
-
# return new_comp
|
295
|
-
|
296
|
-
def add_component_reference(self, comp: SimComponent, ref_comp: SimComponent, slot_extension: str, slot_name: str):
|
297
|
-
|
298
|
-
slot = SimSlot(slot_name, str(slot_extension))
|
299
|
-
ComponentManagement.AddReferencedComponentSlot(comp, slot, self.user)
|
300
|
-
ComponentManagement.AddReferencedComponent(comp, slot, ref_comp, self.user)
|
301
|
-
|
302
|
-
def add_new_geometry_model(self, file_name: str, model_name: str = None, return_resource=False):
|
303
|
-
"""
|
304
|
-
Create and add a new geometry model
|
305
|
-
:param file_name: name of the created .simgeo file
|
306
|
-
:param model_name: name of the geometry model
|
307
|
-
:param return_resource: return the resource
|
308
|
-
:return: GeometryViewer.Model.GeometryModel, geo_resource
|
309
|
-
"""
|
310
|
-
geo_resource = self.add_geometry_resource(file_name)
|
311
|
-
file_info = FileInfo(geo_resource.CurrentFullPath)
|
312
|
-
try:
|
313
|
-
model = SimGeoIO.Load(file_info, self.inst, self.serv)
|
314
|
-
self.models_dict[geo_resource.Key] = model
|
315
|
-
self.serv.AddGeometryModel(model)
|
316
|
-
except ArgumentOutOfRangeException as e:
|
317
|
-
logger.warning(f'Error while loading Model: {model} from {model.File}: {e}. Trying reload...')
|
318
|
-
model = SimGeoIO.Load(file_info, self.inst, self.serv)
|
319
|
-
self.models_dict[geo_resource.Key] = model
|
320
|
-
self.serv.AddGeometryModel(model)
|
321
|
-
|
322
|
-
if model_name is not None:
|
323
|
-
model.Name = model_name
|
324
|
-
|
325
|
-
if return_resource:
|
326
|
-
return model, geo_resource
|
327
|
-
else:
|
328
|
-
return model
|
329
|
-
|
330
|
-
def add_geometry_resource(self, model_name: str):
|
331
|
-
"""
|
332
|
-
Add / create new geometry resource (.simgeo file)
|
333
|
-
:param model_name: name of the new .simgeo file without file extension; Example: 'new_model'
|
334
|
-
"""
|
335
|
-
self.service_provider.GetService[IGeometryViewerService]()
|
336
|
-
new_resource = self.project.AddEmptyGeometryResource(self.project.ProjectUnpackFolder, model_name, self.service_provider)
|
337
|
-
|
338
|
-
return new_resource
|
339
|
-
|
340
|
-
def add_resource(self, filename: str):
|
341
|
-
return self.project.CopyResourceAsContainedFileEntry(FileInfo(filename), self.project.ProjectUnpackFolder)
|
342
|
-
|
343
|
-
def add_table(self, table: SimMultiValueBigTable):
|
344
|
-
self.project_data_manager.ValueManager.Add(table)
|
345
|
-
|
346
|
-
def __del__(self):
|
347
|
-
self.cleanup()
|
348
|
-
|
349
|
-
|
350
|
-
# if __name__ == '__main__':
|
351
|
-
#
|
352
|
-
# # create example templates
|
353
|
-
# templates = create_example_template_bim_bestand_network()
|
354
|
-
#
|
355
|
-
# # write the example templates to a file:
|
356
|
-
# with open('example_templates.yml', mode='w') as f_obj:
|
357
|
-
# yaml.dump(templates, f_obj)
|
358
|
-
#
|
359
|
-
# # load the example templates:
|
360
|
-
# templates = load_templates('example_templates.yml')
|
361
|
-
#
|
362
|
-
# # create classes from the templates:
|
363
|
-
# template_classes = create_template_classes(templates)
|
364
|
-
#
|
365
|
-
# simultan_components = create_example_simultan_components(templates, n=5)
|
366
|
-
#
|
367
|
-
# simultan_components = class_type_simultan_components(simultan_components, template_classes)
|
368
|
-
#
|
369
|
-
# # the simultan components are now of the type which is defined in the templates
|
370
|
-
# print(simultan_components)
|
371
|
-
#
|
372
|
-
# # the class typed components still keep all methods and attributes from simultan:
|
373
|
-
# print(simultan_components[0].simultan_method())
|
374
|
-
#
|
375
|
-
# # and the class typed components have the new defined method python_spec_func:
|
376
|
-
# simultan_components[10].python_spec_func()
|