mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
Add support for deleting attributes in bulk. See #1060.
This commit is contained in:
@@ -1224,15 +1224,11 @@ class AddAttribute(bpy.types.Operator):
|
|||||||
if not bpy.context.active_object.BIMObjectProperties.applicable_attributes:
|
if not bpy.context.active_object.BIMObjectProperties.applicable_attributes:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
name = bpy.context.active_object.BIMObjectProperties.applicable_attributes
|
name = bpy.context.active_object.BIMObjectProperties.applicable_attributes
|
||||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(
|
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(bpy.context.scene.BIMProperties.export_schema)
|
||||||
bpy.context.scene.BIMProperties.export_schema)
|
|
||||||
for obj in bpy.context.selected_objects:
|
for obj in bpy.context.selected_objects:
|
||||||
if (
|
if "/" not in obj.name or obj.BIMObjectProperties.attributes.find(name) != -1:
|
||||||
'/' not in obj.name
|
|
||||||
or obj.BIMObjectProperties.attributes.find(name) != -1
|
|
||||||
):
|
|
||||||
continue
|
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()]:
|
if name not in [a.name() for a in entity.all_attributes()]:
|
||||||
continue
|
continue
|
||||||
attribute = obj.BIMObjectProperties.attributes.add()
|
attribute = obj.BIMObjectProperties.attributes.add()
|
||||||
@@ -1259,7 +1255,13 @@ class RemoveAttribute(bpy.types.Operator):
|
|||||||
attribute_index: bpy.props.IntProperty()
|
attribute_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user