def safeUnlink(obj: Object, protect: bool = True): scn = bpy.context.scene try: unlink_object(obj) except RuntimeError: pass obj.protected = protect obj.use_fake_user = True
def safeLink(obj: Object, protect: bool = False, collections=None): collections = collections or [scn.collection] for coll in collections: try: coll.objects.link(obj) except RuntimeError: continue obj.protected = protect obj.use_fake_user = False
def safe_unlink(obj: Object, protect: bool = True): # unlink object from scene try: unlink_object(obj, all=True) except RuntimeError: pass # prevent object data from being tossed on Blender exit obj.use_fake_user = True # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safe_link(obj: Object, protect: bool = False, collections=None): # link object to scene try: link_object(obj) except RuntimeError: pass # remove fake user from object data obj.use_fake_user = False # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safeUnlink(obj:Object, protect:bool=True): # unlink object from scene try: unlink_object(obj) except RuntimeError: pass # prevent object data from being tossed on Blender exit obj.use_fake_user = True # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safeLink(obj:Object, protect:bool=False, collections=None): # link object to scene try: link_object(obj) except RuntimeError: pass # remove fake user from object data obj.use_fake_user = False # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safe_link(obj: Object, protect: bool = False, collections=[]): # link object to target collections (scene collection by default) collections = collections or [bpy.context.scene.collection] for coll in collections: try: coll.objects.link(obj) except RuntimeError: continue # remove fake user from object data obj.use_fake_user = False # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safeLink(obj:Object, protect:bool=False, collections=None): # link object to target collections (scene collection by default) collections = collections or [bpy.context.scene.collection] for coll in collections: try: coll.objects.link(obj) except RuntimeError: continue # remove fake user from object data obj.use_fake_user = False # protect object from deletion (useful in Bricker addon) if hasattr(obj, "protected"): obj.protected = protect
def safeLink(obj: Object, protect: bool = False): scn = bpy.context.scene link_object(obj) obj.protected = protect obj.use_fake_user = False