From 3a0a9120225806d3adaf407d2a7e3a7f7389557d Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 2 Jul 2025 13:51:43 +0500 Subject: [PATCH] Use `property_unset` instead of `in` and `del` --- src/bonsai/bonsai/bim/module/geometry/prop.py | 10 ++++------ src/bonsai/bonsai/tool/clash.py | 3 +-- src/bonsai/bonsai/tool/owner.py | 3 +-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/geometry/prop.py b/src/bonsai/bonsai/bim/module/geometry/prop.py index 7c3abee06a..1f8e00c11b 100644 --- a/src/bonsai/bonsai/bim/module/geometry/prop.py +++ b/src/bonsai/bonsai/bim/module/geometry/prop.py @@ -193,9 +193,8 @@ def update_is_adding_representation_layer(self: "BIMObjectGeometryProperties", c return return - if "representation_layer" in self: - del self["representation_layer"] - del self["is_adding_representation_layer"] + self.property_unset("representation_layer") + self.property_unset("is_adding_representation_layer") def update_is_editing_item_layer(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None: @@ -216,9 +215,8 @@ def update_is_editing_item_layer(self: "BIMObjectGeometryProperties", context: b self.representation_item_layer = str(layer.id()) return - if "representation_item_layer" in self: - del self["representation_item_layer"] - del self["is_editing_item_layer"] + self.property_unset("representation_item_layer") + self.property_unset("is_editing_item_layer") class BIMObjectGeometryProperties(PropertyGroup): diff --git a/src/bonsai/bonsai/tool/clash.py b/src/bonsai/bonsai/tool/clash.py index 5f110aebab..17582540e4 100644 --- a/src/bonsai/bonsai/tool/clash.py +++ b/src/bonsai/bonsai/tool/clash.py @@ -119,8 +119,7 @@ class Clash(bonsai.core.tool.Clash): if not clash_set: return clash_set.clashes.clear() - if "clashes_loaded" in clash_set: - del clash_set["clashes_loaded"] + clash_set.property_unset("clashes_loaded") @classmethod def load_clash_sets(cls, fn: str) -> None: diff --git a/src/bonsai/bonsai/tool/owner.py b/src/bonsai/bonsai/tool/owner.py index bbd05c7caa..788d0ddb12 100644 --- a/src/bonsai/bonsai/tool/owner.py +++ b/src/bonsai/bonsai/tool/owner.py @@ -319,8 +319,7 @@ class Owner(bonsai.core.tool.Owner): @classmethod def clear_application(cls) -> None: props = cls.get_owner_props() - if "active_application_id" in props: - del props["active_application_id"] + props.property_unset("active_application_id") @classmethod def import_application_attributes(cls) -> None: