Last active
May 21, 2023 18:18
-
-
Save p2or/2d629206158e5c4162a1491bcc6e0e5c to your computer and use it in GitHub Desktop.
Append object of another file (http://blender.stackexchange.com/q/34540) #Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
# current scene | |
scn = bpy.context.scene | |
# path to the blend | |
filepath = "/path/to/file.blend" | |
# name of object to import | |
obj_name = "Cube" | |
# append, set to true to keep the link to the original file | |
link = False | |
# link all objects starting with 'A' | |
with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to): | |
# find all objects named "Cube" | |
data_to.objects = [name for name in data_from.objects if name.startswith(obj_name)] | |
#link object to current scene | |
for obj in data_to.objects: | |
if obj is not None: | |
scn.objects.link(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment