mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 23:12:34 +00:00
Fix edit_attributes triggering name_callback and adding indices to names #6013
It was triggering name_callback, adding indices to the names and writing the name with index to ifc. Also now check previous and new object name explicitly instead of relying on `obj.name` as it may have Blender indices (Blender doesn't support multiple objects sharing the same name).
This commit is contained in:
@@ -125,6 +125,7 @@ class EditAttributes(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
props = obj.BIMAttributeProperties
|
props = obj.BIMAttributeProperties
|
||||||
product = tool.Ifc.get_entity(obj)
|
product = tool.Ifc.get_entity(obj)
|
||||||
assert product
|
assert product
|
||||||
|
object_name = tool.Loader.get_name(product)
|
||||||
|
|
||||||
def callback(attributes, prop):
|
def callback(attributes, prop):
|
||||||
if prop.name in ("RefLatitude", "RefLongitude"):
|
if prop.name in ("RefLatitude", "RefLongitude"):
|
||||||
@@ -140,8 +141,11 @@ class EditAttributes(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
attributes = bonsai.bim.helper.export_attributes(props.attributes, callback=callback)
|
attributes = bonsai.bim.helper.export_attributes(props.attributes, callback=callback)
|
||||||
ifcopenshell.api.run("attribute.edit_attributes", self.file, product=product, attributes=attributes)
|
ifcopenshell.api.run("attribute.edit_attributes", self.file, product=product, attributes=attributes)
|
||||||
|
|
||||||
if (name := tool.Loader.get_name(product)) and obj.name != name:
|
# Ensure Blender doesn't reindex objects if it's not necessary.
|
||||||
obj.name = name
|
# Can't rely on obj.name to detect changed name as it may have Blender indices.
|
||||||
|
if tool.Loader.get_name(product) != object_name:
|
||||||
|
tool.Root.set_object_name(obj, product)
|
||||||
|
|
||||||
bpy.ops.bim.disable_editing_attributes(obj=obj.name)
|
bpy.ops.bim.disable_editing_attributes(obj=obj.name)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user