From 96b8bc638b82f3d9583aaebcd8d8a0e338a67009 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 2 Nov 2020 22:12:31 +1100 Subject: [PATCH] Add support for deleting attributes in bulk. See #1060. --- .../blenderbim/bim/operator.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 3a3f06f3a4..ffb73219e1 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1224,15 +1224,11 @@ class AddAttribute(bpy.types.Operator): 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) + 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 - ): + if "/" not in obj.name or obj.BIMObjectProperties.attributes.find(name) != -1: continue - entity = schema.declaration_by_name(obj.name.split('/')[0]) + 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() @@ -1259,7 +1255,13 @@ class RemoveAttribute(bpy.types.Operator): attribute_index: bpy.props.IntProperty() def execute(self, context): - bpy.context.active_object.BIMObjectProperties.attributes.remove(self.attribute_index) + name = bpy.context.active_object.BIMObjectProperties.attributes[self.attribute_index].name + for obj in bpy.context.selected_objects: + if "/" not in obj.name: + continue + index = obj.BIMObjectProperties.attributes.find(name) + if index != -1: + obj.BIMObjectProperties.attributes.remove(index) return {"FINISHED"}