See #4240. Guard against possible user creating invalid userdefined attribute values.

This commit is contained in:
Dion Moult
2024-01-21 21:56:45 +11:00
parent c88496c6a6
commit ab80400e16
@@ -50,5 +50,18 @@ class Usecase:
def execute(self):
for name, value in self.settings["attributes"].items():
setattr(self.settings["product"], name, value)
if hasattr(self.settings["product"], "PredefinedType"):
if hasattr(self.settings["product"], "ElementType"):
if (
not self.settings["product"].ElementType
and self.settings["product"].PredefinedType == "USERDEFINED"
):
self.settings["product"].PredefinedType = "NOTDEFINED"
elif hasattr(self.settings["product"], "ObjectType"):
if (
not self.settings["product"].ObjectType
and self.settings["product"].PredefinedType == "USERDEFINED"
):
self.settings["product"].PredefinedType = "NOTDEFINED"
if hasattr(self.settings["product"], "OwnerHistory"):
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})