Fix bug where append_asset would pull in openings unnecessarily

If you try to append an asset which has a relationship such as
IfcRelAssociatesClassification to a whole bunch of opening elements, all
those openings will also (incorrectly) be pulled in.
This commit is contained in:
Dion Moult
2025-08-12 18:37:25 +10:00
parent 3e5a2e5eb2
commit 55e97fd170
@@ -472,7 +472,14 @@ class Usecase:
for i, attribute in enumerate(element):
new_attribute = None
if isinstance(attribute, ifcopenshell.entity_instance):
if not self.is_another_asset(attribute):
# Void and projection relationships are special because they
# are "dependent" relationships, so we always consider them.
# We do _not_ whitelist (i.e. in is_another_asset)
# IfcFeatureElement because you can have things like
# IfcRelAssociatesClassification to openings! We only ever want
# to consider IfcFeatureElements in IfcRelVoidsElements and
# IfcRelProjectsElements.
if element.is_a() in ("IfcRelVoidsElement", "IfcRelProjectsElement") or not self.is_another_asset(attribute):
new_attribute = self.add_element(attribute)
elif isinstance(attribute, tuple) and attribute and isinstance(attribute[0], ifcopenshell.entity_instance):
new_attribute = []
@@ -500,9 +507,6 @@ class Usecase:
"""Is IFC entity from inverse attribute is another asset to append that should be skipped."""
if element == self.settings["element"]:
return False
elif element.is_a("IfcFeatureElement"):
# Feature elements match the target class but aren't considered "assets"
return False
elif element.is_a("IfcRoot") and self.by_guid(element.GlobalId) is not None:
return False
elif element.is_a(self.target_class):