2021-03-11 10:46:55 +11:00
|
|
|
class Data:
|
|
|
|
|
is_loaded = False
|
|
|
|
|
products = {}
|
|
|
|
|
structural_analysis_models = {}
|
2021-03-30 01:12:33 +02:00
|
|
|
boundary_conditions = {}
|
|
|
|
|
connected_structural_members = {}
|
|
|
|
|
connection_conditions = {}
|
2021-03-11 10:46:55 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def purge(cls):
|
|
|
|
|
cls.is_loaded = False
|
|
|
|
|
cls.products = {}
|
2021-03-30 01:12:33 +02:00
|
|
|
cls.structural_analysis_models = {}
|
2021-03-24 00:10:07 +01:00
|
|
|
cls.boundary_conditions = {}
|
2021-03-24 00:15:22 +01:00
|
|
|
cls.connected_structural_members = {}
|
2021-03-30 01:12:33 +02:00
|
|
|
cls.connection_conditions = {}
|
2021-03-11 10:46:55 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
2021-03-25 10:48:31 +11:00
|
|
|
def load(cls, file, product_id=None):
|
|
|
|
|
cls._file = file
|
2021-03-30 01:12:33 +02:00
|
|
|
if not cls._file:
|
|
|
|
|
return
|
2021-03-19 10:55:52 +11:00
|
|
|
if product_id:
|
|
|
|
|
return cls.load_structural_connection(product_id)
|
|
|
|
|
cls.load_structural_analysis_models()
|
|
|
|
|
cls.is_loaded = True
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def load_structural_analysis_models(cls):
|
2021-03-30 01:12:33 +02:00
|
|
|
cls.products = {}
|
|
|
|
|
cls.structural_analysis_models = {}
|
|
|
|
|
|
2021-03-25 10:48:31 +11:00
|
|
|
for model in cls._file.by_type("IfcStructuralAnalysisModel"):
|
2021-03-11 10:46:55 +11:00
|
|
|
if model.IsGroupedBy:
|
|
|
|
|
for rel in model.IsGroupedBy:
|
|
|
|
|
for product in rel.RelatedObjects:
|
|
|
|
|
cls.products.setdefault(product.id(), []).append(model.id())
|
|
|
|
|
data = model.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
del data["OrientationOf2DPlane"]
|
|
|
|
|
|
|
|
|
|
loaded_by = []
|
|
|
|
|
for load_group in model.LoadedBy or []:
|
|
|
|
|
loaded_by.append(load_group.id())
|
|
|
|
|
data["LoadedBy"] = loaded_by
|
|
|
|
|
|
|
|
|
|
has_results = []
|
|
|
|
|
for result_group in model.HasResults or []:
|
|
|
|
|
has_results.append(result_group.id())
|
|
|
|
|
data["HasResults"] = has_results
|
|
|
|
|
|
2021-03-30 01:12:33 +02:00
|
|
|
data["SharedPlacement"] = model.SharedPlacement.id()
|
|
|
|
|
|
2021-03-11 10:46:55 +11:00
|
|
|
cls.structural_analysis_models[model.id()] = data
|
2021-03-19 10:55:52 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def load_structural_connection(cls, product_id):
|
2021-03-30 01:12:33 +02:00
|
|
|
cls.boundary_conditions = {}
|
|
|
|
|
cls.connected_structural_members = {}
|
|
|
|
|
# cls.connection_conditions = {}
|
|
|
|
|
|
2021-03-25 10:48:31 +11:00
|
|
|
connection = cls._file.by_id(product_id)
|
2021-03-19 10:55:52 +11:00
|
|
|
if connection.AppliedCondition:
|
|
|
|
|
data = connection.AppliedCondition.get_info()
|
|
|
|
|
for key, value in data.items():
|
|
|
|
|
if not value or key in ["Name", "type", "id"]:
|
|
|
|
|
continue
|
|
|
|
|
data[key] = value.wrappedValue
|
|
|
|
|
else:
|
|
|
|
|
data = {}
|
2021-03-24 00:10:07 +01:00
|
|
|
cls.boundary_conditions[connection.id()] = data
|
2021-03-24 00:15:22 +01:00
|
|
|
|
2021-03-30 01:12:33 +02:00
|
|
|
cls.connected_structural_members[connection.id()] = {}
|
|
|
|
|
for rel in connection.ConnectsStructuralMembers or []:
|
|
|
|
|
data = rel.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
data["RelatingStructuralMember"] = rel.RelatingStructuralMember.id()
|
|
|
|
|
data["RelatedStructuralConnection"] = rel.RelatedStructuralConnection.id()
|
|
|
|
|
del data["ConditionCoordinateSystem"] # TODO: consider orientation
|
|
|
|
|
del data["AppliedCondition"] # delete and parse below
|
|
|
|
|
if rel.is_a("IfcRelConnectsWithEccentricity"):
|
|
|
|
|
data["ConnectionConstraint"] = rel.ConnectionConstraint # TODO
|
|
|
|
|
|
|
|
|
|
cls.connected_structural_members[connection.id()][rel.id()] = data
|
|
|
|
|
|
|
|
|
|
if rel.AppliedCondition:
|
|
|
|
|
data = rel.AppliedCondition.get_info()
|
|
|
|
|
for key, value in data.items():
|
|
|
|
|
if not value or key in ["Name", "type", "id"]:
|
|
|
|
|
continue
|
|
|
|
|
data[key] = value.wrappedValue
|
|
|
|
|
else:
|
|
|
|
|
data = {}
|
|
|
|
|
cls.connection_conditions[rel.id()] = data
|
|
|
|
|
|
|
|
|
|
print(cls.connected_structural_members)
|
|
|
|
|
print(cls.connection_conditions)
|
2021-03-24 00:15:22 +01:00
|
|
|
|
2021-03-30 01:12:33 +02:00
|
|
|
# cls.connected_structural_members[connection.id()] = [
|
|
|
|
|
# rel.id()
|
|
|
|
|
# for rel in connection.ConnectsStructuralMembers or []
|
|
|
|
|
# ]
|