Remove container executes on all selected objects

This commit is contained in:
Gorgious
2021-08-24 13:24:22 +02:00
parent cb4001b47b
commit d2ab13c3cb
@@ -134,7 +134,8 @@ class RemoveContainer(bpy.types.Operator):
return IfcStore.execute_ifc_operator(self, context) return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context): def _execute(self, context):
obj = bpy.data.objects.get(self.obj, context.active_object) active_object = context.active_object
for obj in [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects:
oprops = obj.BIMObjectProperties oprops = obj.BIMObjectProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
ifcopenshell.api.run( ifcopenshell.api.run(
@@ -152,7 +153,7 @@ class RemoveContainer(bpy.types.Operator):
for collection in obj.users_collection: for collection in obj.users_collection:
collection.objects.unlink(obj) collection.objects.unlink(obj)
context.scene.collection.objects.link(obj) context.scene.collection.objects.link(obj)
context.view_layer.objects.active = obj context.view_layer.objects.active = active_object
return {"FINISHED"} return {"FINISHED"}
def remove_collection(self, parent, child): def remove_collection(self, parent, child):