From 3feef9f5abe935f302fc4a2dadf2642e7df28125 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Wed, 7 Aug 2024 11:49:49 +0200 Subject: [PATCH] function to completely delete add function to completely delete objects safely --- butils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/butils.py b/butils.py index de645db..33349a5 100644 --- a/butils.py +++ b/butils.py @@ -486,6 +486,22 @@ def ShowMessageBox(title = "Message Box", icon = 'INFO', message=""): self.layout.label(text=n) bpy.context.window_manager.popup_menu(draw, title = title, icon = icon) +def completely_delete_objs(objs): + context_override = bpy.context.copy() + context_override["selected_objects"] = list(objs) + with bpy.context.temp_override(**context_override): + bpy.ops.object.delete() + + # remove deleted objects + # this is necessary + for g in objs: + if type(g) != type(None): + try: + bpy.data.objects.remove(g, do_unlink=True) + except ReferenceError as e: + # not important + pass + def set_text_on_curve(text_properties): # starttime = time.perf_counter_ns() mom = text_properties.text_object