bim.copy_attribute_to_selection - add info message

It's important to have somewhere information on how many elements were actually affected since some of the selected objects may not support the used attribute.

Example - https://i.imgur.com/UrLNWcF.png
This commit is contained in:
Andrej730
2025-01-22 16:16:55 +05:00
parent 23a6721f8e
commit 882bacf91a
2 changed files with 8 additions and 2 deletions
@@ -202,5 +202,9 @@ class CopyAttributeToSelection(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
value = context.active_object.BIMAttributeProperties.attributes.get(self.name).get_value()
i = 0
for obj in tool.Blender.get_selected_objects():
core.copy_attribute_to_selection(tool.Ifc, name=self.name, value=value, obj=obj)
success = core.copy_attribute_to_selection(tool.Ifc, name=self.name, value=value, obj=obj)
if success:
i += 1
self.report({"INFO"}, f"Attribute was successfully copied to {i} elements.")
+3 -1
View File
@@ -25,10 +25,12 @@ if TYPE_CHECKING:
import bonsai.tool as tool
def copy_attribute_to_selection(ifc: tool.Ifc, name: str, value: Union[str, None], obj: bpy.types.Object) -> None:
def copy_attribute_to_selection(ifc: tool.Ifc, name: str, value: Union[str, None], obj: bpy.types.Object) -> bool:
element = ifc.get_entity(obj)
if element:
try:
ifc.run("attribute.edit_attributes", product=element, attributes={name: value})
return True
except:
pass
return False