WIP implement void module with add / remove openings. See #1222.

This commit is contained in:
Dion Moult
2021-01-12 15:12:53 +11:00
parent 1836136049
commit 9400eab0ff
10 changed files with 282 additions and 78 deletions
@@ -0,0 +1,53 @@
from blenderbim.bim.ifc import IfcStore
class Data:
products = {}
openings = {}
fillings = {}
@classmethod
def load(cls, product_id):
print('loading', product_id)
file = IfcStore.get_file()
if not file:
return
cls.products[product_id] = set()
product = file.by_id(product_id)
for rel in file.by_type("IfcRelVoidsElement"):
building_element = rel.RelatingBuildingElement
if building_element != product:
continue
opening = rel.RelatedOpeningElement
opening_id = int(opening.id())
cls.products[product_id].add(opening_id)
cls.openings[opening_id] = {"Name": opening.Name, "HasFillings": set()}
for rel in file.by_type("IfcRelFillsElement"):
opening = rel.RelatingOpeningElement
opening_id = int(opening.id())
if opening_id not in cls.openings:
continue
filling = rel.RelatedBuildingElement
filling_id = int(filling.id())
cls.fillings[filling_id] = {"Name": filling.Name, "FillsVoid": opening_id}
cls.openings[opening_id]["HasFillings"].add(filling_id)
return # See bug #1224
#if not hasattr(product, "HasOpenings") or not product.HasOpenings:
# return
#for rel_voids_element in product.HasOpenings:
# opening = rel_voids_element.RelatedOpeningElement
# opening_id = int(opening.id())
# fillings = []
# if opening.HasFillings:
# for rel_fills_element in opening.HasFillings:
# filling = rel_fills_element.RelatedBuildingElement
# filling_id = int(filling.id())
# fillings.append(filling_id)
# cls.fillings[filling_id] = {
# "Name": filling.Name,
# }
# cls.openings[opening_id] = {
# "Name": opening.Name,
# "HasFillings": fillings,
# }
# cls.products[product_id].append(opening_id)