Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
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
Esempio n. 9
0
def safeLink(obj: Object, protect: bool = False):
    scn = bpy.context.scene
    link_object(obj)
    obj.protected = protect
    obj.use_fake_user = False