Fix bug with the first object rename after class assignment

The problem was that during class assignment, it was setting the object name and `is_renaming` flag but only then linking to IFC. Since object wasn't linked to IFC, name callback wasn't triggered and `is_renaming` wasn't reset and first rename wouldn't work.
Now it's just not setting the flag if object is not linked to IFC, as there's no callback then and don't need to protect from it.
This commit is contained in:
Andrej730
2025-04-10 17:37:08 +05:00
parent 9407faf1f9
commit d8102d848d
2 changed files with 12 additions and 3 deletions
+8 -1
View File
@@ -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")
+4 -2
View File
@@ -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