mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
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:
@@ -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.")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user