fix removing objects with materials after c4ae9578e #4843

temporary fix, we probably should indeed just get rid of that listener
This commit is contained in:
Andrej730
2024-06-24 17:17:10 +05:00
parent cbb7c5620d
commit 115844279f
@@ -526,6 +526,16 @@ def ensure_material_assigned(usecase_path: str, ifc_file: ifcopenshell.file, set
def ensure_material_unassigned(usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None:
elements = settings["products"]
# unassign_material could be called when product is about to get removed
# and representation might be already removed.
elements = [
e
for e in elements
if (obj := tool.Ifc.get_object(e))
and obj.data
and tool.Ifc.get_entity_by_id(obj.data.BIMMeshProperties.ifc_definition_id)
]
for element in elements[:]:
if element.is_a("IfcElementType"):
elements.extend(tool.Model.get_occurrences_without_material_override(element))