예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #9
0
def safeLink(obj: Object, protect: bool = False):
    scn = bpy.context.scene
    link_object(obj)
    obj.protected = protect
    obj.use_fake_user = False