mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +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):
|
def _execute(self, context):
|
||||||
value = context.active_object.BIMAttributeProperties.attributes.get(self.name).get_value()
|
value = context.active_object.BIMAttributeProperties.attributes.get(self.name).get_value()
|
||||||
|
i = 0
|
||||||
for obj in tool.Blender.get_selected_objects():
|
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
|
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)
|
element = ifc.get_entity(obj)
|
||||||
if element:
|
if element:
|
||||||
try:
|
try:
|
||||||
ifc.run("attribute.edit_attributes", product=element, attributes={name: value})
|
ifc.run("attribute.edit_attributes", product=element, attributes={name: value})
|
||||||
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user