diff --git a/src/bonsai/bonsai/bim/prop.py b/src/bonsai/bonsai/bim/prop.py index af378bb8f4..45128271b1 100644 --- a/src/bonsai/bonsai/bim/prop.py +++ b/src/bonsai/bonsai/bim/prop.py @@ -620,7 +620,14 @@ class BIMObjectProperties(PropertyGroup): ) cartesian_point_offset: StringProperty(name="Cartesian Point Offset") is_reassigning_class: BoolProperty(name="Is Reassigning Class") - is_renaming: BoolProperty(name="Is Renaming", default=False) + is_renaming: BoolProperty( + name="Is Renaming", + description=( + "Flag to ensure object name callback wouldn't write new name to IFC. " + "Automatically reset to `False` after the next callback." + ), + default=False, + ) location_checksum: StringProperty(name="Location Checksum") rotation_checksum: StringProperty(name="Rotation Checksum") diff --git a/src/bonsai/bonsai/tool/root.py b/src/bonsai/bonsai/tool/root.py index bb6aa116c0..5c67e20066 100644 --- a/src/bonsai/bonsai/tool/root.py +++ b/src/bonsai/bonsai/tool/root.py @@ -419,7 +419,9 @@ class Root(bonsai.core.tool.Root): name = tool.Loader.get_name(element) if obj.name != name: props = tool.Blender.get_object_bim_props(obj) - props.is_renaming = True + # If it's not an IFC object, then it doesn't have a name callback. + # So, we need to protect it writing to IFC. + props.is_renaming = bool(tool.Ifc.get_entity(obj)) obj.name = name # The handler will trigger, and reset is_renaming to False @classmethod @@ -428,7 +430,7 @@ class Root(bonsai.core.tool.Root): if material.name == name: return msprops = tool.Style.get_material_style_props(material) - msprops.is_renaming = True + msprops.is_renaming = bool(tool.Ifc.get_entity(material)) material.name = name # The handler will trigger, and reset is_renaming to False. @classmethod