PySimultan 0.7.1__py3-none-any.whl → 0.7.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
PySimultan2/__about__.py CHANGED
@@ -1 +1 @@
1
- version = '0.7.1'
1
+ version = '0.7.3'
PySimultan2/data_model.py CHANGED
@@ -474,7 +474,7 @@ class DataModel:
474
474
  :param return_resource: return the resource
475
475
  :return: GeometryViewer.Model.GeometryModel, geo_resource
476
476
  """
477
- self.get_file_infos.cache_clear()
477
+ self.get_file_infos_cached.cache_clear()
478
478
  geo_resource = self.add_geometry_resource(file_name)
479
479
  file_info = SystemFileInfo(geo_resource.CurrentFullPath)
480
480
  try:
@@ -505,7 +505,7 @@ class DataModel:
505
505
  model_name,
506
506
  self.service_provider)
507
507
 
508
- self.get_file_infos.cache_clear()
508
+ self.get_file_infos_cached.cache_clear()
509
509
  return new_resource
510
510
 
511
511
  def add_empty_resource(self,
@@ -519,7 +519,7 @@ class DataModel:
519
519
  """
520
520
  # return self.project.AddResourceFile(FileInfo(str(filename)))
521
521
 
522
- self.get_file_infos.cache_clear()
522
+ self.get_file_infos_cached.cache_clear()
523
523
  if target_dir is None:
524
524
  return self.project.AddEmptyResource(SystemFileInfo(str(filename)))
525
525
  else:
@@ -701,7 +701,7 @@ class DataModel:
701
701
  logger.info(f'Deleted resource {resource.Name} from project {self.project_path}')
702
702
  else:
703
703
  logger.error(f'Could not delete resource {resource.Name} from project {self.project_path}')
704
- self.get_file_infos.cache_clear()
704
+ self.get_file_infos_cached.cache_clear()
705
705
  return success
706
706
 
707
707
  def get_existing_resource_directory_entry(self,
@@ -974,11 +974,13 @@ class DataModel:
974
974
  self.component_dict = {x.Id: x for x in component_list}
975
975
  return self.component_dict
976
976
 
977
- @lru_cache()
978
977
  def get_component_by_id(self,
979
- item_id: SimId,
978
+ item_id: Union[SimId, int],
980
979
  search_subcomponents=False) -> Union[SimComponent, None]:
981
980
 
981
+ if isinstance(item_id, int):
982
+ item_id = SimId(self.project.GlobalID, item_id)
983
+
982
984
  # print(item_id.GlobalId, item_id.LocalId)
983
985
  # _ = [print((x.Id.GlobalId, x.Id.LocalId)) for x in self.data.Items]
984
986
 
@@ -1004,6 +1006,7 @@ class DataModel:
1004
1006
  if component is None and search_subcomponents:
1005
1007
  component = self.component_dict.get(item_id, None)
1006
1008
  if component is None:
1009
+ self.create_component_dict.cache_clear()
1007
1010
  self.create_component_dict()
1008
1011
  component = self.component_dict.get(item_id, None)
1009
1012
 
@@ -1012,8 +1015,22 @@ class DataModel:
1012
1015
  def get_component_by_name(self, name: str) -> list[SimComponent]:
1013
1016
  return [x for x in self.create_component_dict.values() if x.Name == name]
1014
1017
 
1015
- @lru_cache()
1016
1018
  def get_file_infos(self) -> list[PythonFileInfo]:
1019
+ """
1020
+ Get all file infos from the project
1021
+ :return: list of PythonFileInfo objects
1022
+ """
1023
+ file_infos = self.get_file_infos_cached()
1024
+ if file_infos.__len__() != self.assets.__len__():
1025
+ logger.warning(f'No file infos found in project {self.project_path}. '
1026
+ f'Please check if the project is loaded correctly.')
1027
+ # try to reload the file infos
1028
+ self.get_file_infos_cached.cache_clear()
1029
+
1030
+ return self.get_file_infos_cached()
1031
+
1032
+ @lru_cache()
1033
+ def get_file_infos_cached(self) -> list[PythonFileInfo]:
1017
1034
  file_infos = []
1018
1035
  for asset in self.assets:
1019
1036
  if isinstance(asset, ResourceFileEntry):
@@ -13,6 +13,7 @@ from .geometry.utils import create_python_geometry
13
13
 
14
14
  from SIMULTAN.Data.Geometry import (Layer, Vertex, Edge, PEdge, Face, Volume, EdgeLoop)
15
15
  from SIMULTAN.Data.Components import SimComponent
16
+ from SIMULTAN.Data import SimId
16
17
  from .geometry.geometry_base import (SimultanLayer, SimultanVertex, SimultanEdge, SimultanEdgeLoop, SimultanFace,
17
18
  SimultanVolume)
18
19
 
@@ -457,6 +458,18 @@ class PythonMapper(object):
457
458
  except IndexError:
458
459
  return None
459
460
 
461
+ def get_mapped_object_by_id(self,
462
+ component_id: Union[SimId, int],
463
+ data_model: 'DataModel',
464
+ search_subcomponents: bool = True) -> Optional[SimultanObject]:
465
+
466
+ component = data_model.get_component_by_id(component_id, search_subcomponents=search_subcomponents)
467
+ if component is None:
468
+ logger.error(f'Component with id {id} not found in the data model')
469
+ return None
470
+ typed_object = self.create_python_object(component, data_model=data_model)
471
+ return typed_object
472
+
460
473
  def __repr__(self):
461
474
  return f'PythonMapper(module={self.module}, {len(self.registered_classes)} registered classes)'
462
475
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PySimultan
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Project-URL: Documentation, https://github.com/Bühler Maximilian/PySimultan2#readme
5
5
  Project-URL: Issues, https://github.com/Bühler Maximilian/PySimultan2/issues
6
6
  Project-URL: Source, https://github.com/Bühler Maximilian/PySimultan2
@@ -1,11 +1,11 @@
1
1
  PySimultan2/CHANGELOG.md,sha256=sFTVr_AgFyqf4HPmShaAHKaHcT5A3MjL2s2VVzEdoyM,1340
2
- PySimultan2/__about__.py,sha256=CofaMtE6-CSasTw6dBDKRTVix5Q4zlkB7yu8mbXp9uk,19
2
+ PySimultan2/__about__.py,sha256=Yl5Obh3nV2cgQAb9sShmU5W55HPrpYbI_WGlWqZ5S6Y,19
3
3
  PySimultan2/__init__.py,sha256=PGVR1uhY01dF5tHyad-znURUZ_LVB95vsjId2BT0aJM,3245
4
- PySimultan2/data_model.py,sha256=7qYAVHT8IbbKUy25g0CiPQrloLh7ukReIThatVGcWEs,45109
4
+ PySimultan2/data_model.py,sha256=3KX3cjsEB-9G-FzRVd0Zo1FpoAgR8cFOCo-drPoXJKg,45894
5
5
  PySimultan2/default_types.py,sha256=NnBgf16CElEAWH7tA0qLKqFHZ4_YS00HAJpKHG1CmjQ,30581
6
6
  PySimultan2/files.py,sha256=8JCWtUPS89POsPrmn_kCrHzmiBsLb1iWhw-A9qQLcR8,34716
7
7
  PySimultan2/multi_values.py,sha256=CkmfifA-mHL3Cnm496tGQuUchpmNF7JCulyrhUFAM_I,15638
8
- PySimultan2/object_mapper.py,sha256=iVjQBV0mwVxCxSCloBrV0Jq8oR9BG34EIEf90bXweHM,19912
8
+ PySimultan2/object_mapper.py,sha256=0qiVEjn6q24u2_YZGOyD4ESXZ-0tfJjGjSowT8wa2wM,20568
9
9
  PySimultan2/simultan_object.py,sha256=-3dTlkyoVdrXmSZgozz7fTHJnaxN63utYPXOXTCuEOY,20837
10
10
  PySimultan2/taxonomy_maps.py,sha256=hhgXhRXIPTD2briG_yYZssJ9musOnzs0LC4e8e78e40,10323
11
11
  PySimultan2/type_setter_lookup.py,sha256=PGa5_EtV7SM15w3uxy0fA3LiQ0TaS4Ys0LYR5zs8aNk,3748
@@ -44,7 +44,7 @@ PySimultan2/resources/System.Data.OleDb.dll,sha256=-AAzdmyo01QNgD9qnUIewEImplJFV
44
44
  PySimultan2/resources/System.Net.Http.Formatting.dll,sha256=xQBIin4YpqDObdqwau_5dr8XQEq54hlxV4gBgNtUqbc,179672
45
45
  PySimultan2/resources/System.Reflection.MetadataLoadContext.dll,sha256=P4PBRwAGWL27sNc754Wd28t_koJKBFYJ2FyolrD1xo0,242296
46
46
  PySimultan2/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
- pysimultan-0.7.1.dist-info/METADATA,sha256=J-zJleZLZr1YGrUvr9Jdj2FugAslZm_K-jIybKZboow,6608
48
- pysimultan-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- pysimultan-0.7.1.dist-info/licenses/LICENSE.txt,sha256=FgR_YZkk7oYz4087xYXfcBCXGuTStFrsOWTH4bbpa3c,1821
50
- pysimultan-0.7.1.dist-info/RECORD,,
47
+ pysimultan-0.7.3.dist-info/METADATA,sha256=ZDkGZr0z2LnB2G2eMgKHQdb2tIM8nMeCT5Plo4C_2Tc,6608
48
+ pysimultan-0.7.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
+ pysimultan-0.7.3.dist-info/licenses/LICENSE.txt,sha256=FgR_YZkk7oYz4087xYXfcBCXGuTStFrsOWTH4bbpa3c,1821
50
+ pysimultan-0.7.3.dist-info/RECORD,,