From ba8689468ee448624ab6421b6f6cbc252100e577 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 2 Nov 2020 22:05:32 +1100 Subject: [PATCH] You can now add attributes in bulk by selecting multiple before adding. See #1060. --- .../blenderbim/bim/operator.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 5a21e09955..3a3f06f3a4 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1221,9 +1221,22 @@ class AddAttribute(bpy.types.Operator): bl_label = "Add Attribute" def execute(self, context): - if bpy.context.active_object.BIMObjectProperties.applicable_attributes: - attribute = bpy.context.active_object.BIMObjectProperties.attributes.add() - attribute.name = bpy.context.active_object.BIMObjectProperties.applicable_attributes + if not bpy.context.active_object.BIMObjectProperties.applicable_attributes: + return {"FINISHED"} + name = bpy.context.active_object.BIMObjectProperties.applicable_attributes + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name( + bpy.context.scene.BIMProperties.export_schema) + for obj in bpy.context.selected_objects: + if ( + '/' not in obj.name + or obj.BIMObjectProperties.attributes.find(name) != -1 + ): + continue + entity = schema.declaration_by_name(obj.name.split('/')[0]) + if name not in [a.name() for a in entity.all_attributes()]: + continue + attribute = obj.BIMObjectProperties.attributes.add() + attribute.name = name if attribute.name == "GlobalId": attribute.string_value = ifcopenshell.guid.new() return {"FINISHED"}