Skip to content

Instantly share code, notes, and snippets.

@p2or
Last active May 21, 2023 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save p2or/2d629206158e5c4162a1491bcc6e0e5c to your computer and use it in GitHub Desktop.
Save p2or/2d629206158e5c4162a1491bcc6e0e5c to your computer and use it in GitHub Desktop.
Append object of another file (http://blender.stackexchange.com/q/34540) #Blender
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