From 7d944255d02ccca094d2eccd685bd8a039ddf431 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 2 Feb 2023 18:26:14 +1100 Subject: [PATCH] Fix bug where you could unassign a material usage and create an invalid parametric occurrence --- .../ifcopenshell/api/material/unassign_material.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py index 96b211d79f..e4517f500b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py +++ b/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py @@ -75,7 +75,11 @@ class Usecase: for rel in self.settings["product"].HasAssociations: if rel.is_a("IfcRelAssociatesMaterial"): if rel.RelatingMaterial.is_a() in ["IfcMaterialLayerSetUsage", "IfcMaterialProfileSetUsage"]: - self.file.remove(rel.RelatingMaterial) + # Usages cannot be unassigned, as all occurrences of a type + # which has a parametric material must use the parametric + # material. Instead, unassign the parametric material from + # the type. + continue if len(rel.RelatedObjects) == 1: self.file.remove(rel) continue