2021-01-03 19:09:01 +11:00
|
|
|
class Data:
|
|
|
|
|
products = {}
|
2021-01-06 10:28:22 +11:00
|
|
|
representations = {}
|
2021-02-03 17:30:19 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def purge(cls):
|
2021-02-04 21:59:08 +11:00
|
|
|
cls.products = {}
|
2021-02-03 17:30:19 +11:00
|
|
|
cls.representations = {}
|
2021-01-03 19:09:01 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
2021-03-25 10:48:31 +11:00
|
|
|
def load(cls, file, product_id):
|
2021-01-03 19:09:01 +11:00
|
|
|
if not file:
|
|
|
|
|
return
|
2021-01-06 10:28:22 +11:00
|
|
|
cls.products[product_id] = []
|
2021-01-03 19:09:01 +11:00
|
|
|
product = file.by_id(product_id)
|
2021-02-07 11:44:14 +11:00
|
|
|
representations = []
|
2021-05-18 14:36:12 +10:00
|
|
|
if product.is_a("IfcProduct") and product.Representation:
|
|
|
|
|
representations = product.Representation.Representations
|
2021-02-07 11:44:14 +11:00
|
|
|
elif product.is_a("IfcTypeProduct"):
|
2021-02-16 11:12:28 +11:00
|
|
|
representations = [rm.MappedRepresentation for rm in product.RepresentationMaps or []]
|
2021-02-07 11:44:14 +11:00
|
|
|
for representation in representations:
|
2021-01-03 19:09:01 +11:00
|
|
|
c = representation.ContextOfItems
|
2021-01-06 10:28:22 +11:00
|
|
|
rep_id = int(representation.id())
|
|
|
|
|
cls.representations[rep_id] = {
|
2021-01-03 19:09:01 +11:00
|
|
|
"RepresentationIdentifier": representation.RepresentationIdentifier,
|
|
|
|
|
"RepresentationType": representation.RepresentationType,
|
|
|
|
|
"ContextOfItems": {
|
|
|
|
|
"ContextType": c.ContextType,
|
|
|
|
|
"ContextIdentifier": c.ContextIdentifier,
|
|
|
|
|
"TargetView": c.TargetView if c.is_a("IfcGeometricRepresentationSubContext") else "",
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-06 10:28:22 +11:00
|
|
|
cls.products[product_id].append(rep_id)
|