Fix #3050. Unlinking now gives you an option to delete as well.

This commit is contained in:
Dion Moult
2023-05-28 13:52:23 +10:00
parent 6537d9dd71
commit 566ea1c283
@@ -156,6 +156,7 @@ class UnlinkObject(bpy.types.Operator):
bl_label = "Unlink Object"
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty()
should_delete: bpy.props.BoolProperty(name="Should Delete", default=True)
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
@@ -167,7 +168,14 @@ class UnlinkObject(bpy.types.Operator):
else:
objects = context.selected_objects
for obj in objects:
if obj.BIMObjectProperties.ifc_definition_id:
element = tool.Ifc.get_entity(obj)
if element:
if self.should_delete:
obj_copy = obj.copy()
for collection in obj.users_collection:
collection.objects.link(obj_copy)
tool.Geometry.delete_ifc_object(obj)
obj = obj_copy
if obj in IfcStore.edited_objs:
IfcStore.edited_objs.remove(obj)
IfcStore.unlink_element(obj=obj)
@@ -182,6 +190,13 @@ class UnlinkObject(bpy.types.Operator):
obj.name = "/".join(obj.name.split("/")[1:])
return {"FINISHED"}
def draw(self, context):
row = self.layout.row()
row.prop(self, "should_delete")
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
class CopyClass(bpy.types.Operator, Operator):
bl_idname = "bim.copy_class"