I'm searching a way to append a group in Python.

It should behave exactly like the Append function (ShiftF1) works, all objects should be local and editable. The idea is to append a character (with rig etc.) via Python and not Link it (to be able to modify it without making everything local one by one).


  • $\begingroup$ Would you know ahead of time the blend file and path, as well as the exact group name that you want to append? Or do you need some type of browsing interface? $\endgroup$ – Todd McIntosh Jul 25 '15 at 22:42
  • $\begingroup$ I already know blend, path and group name $\endgroup$ – Boris Jul 25 '15 at 23:01

Here's a solution. It appends an instance of the group:

import bpy

filepath = "/path/to/file.blend"
group_name = "CubeGroup"

# append, set to true to keep the link to the original file
link = False 

# append all groups from the .blend file
with bpy.data.libraries.load(filepath, link=link) as (data_src, data_dst):
    ## all groups
    # data_to.groups = data_from.groups

    # only append a single group we already know the name of
    data_dst.groups = [group_name]

# add the group instance to the scene
for group in data_dst.groups:
    ob = bpy.data.objects.new(group.name, None)
    ob.dupli_group = group
    ob.dupli_type = 'GROUP'
    #bpy.context.scene.objects.link(ob) # # Blender 2.7x
    bpy.context.collection.objects.link(ob) # Blender 2.8x

Credit: solution is based on this answer: Import object without bpy.ops.wm.link_append

It's basically the same for objects:

import bpy

# path to the blend
filepath = "/path/to/file.blend"

# name of object(s) to append or link
obj_name = "Cube"

# append, set to true to keep the link to the original file
link = False

# link all objects starting with 'Cube'
with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
    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:
       #bpy.context.scene.objects.link(obj) # Blender 2.7x
       bpy.context.collection.objects.link(obj) # Blender 2.8x

Further information: https://www.blender.org/api/current/bpy.types.BlendDataLibraries.html

|improve this answer|||||
  • 2
    $\begingroup$ Sorry but this don't make it. This is the solution i have already, that's why i specified "behave like the append operator(shift F1) with everything local/editable". Here it behave like a link (ctrl alt o). i ll edit my first post to be more clear $\endgroup$ – Boris Jul 26 '15 at 9:55
  • 4
    $\begingroup$ @Boris, There is a link argument, Set it to False to behave like Append $\endgroup$ – ideasman42 Sep 5 '15 at 12:52
  • $\begingroup$ In Blender 2.8 replace bpy.context.scene.objects.link(obj) with bpy.context.collection.objects.link(obj) $\endgroup$ – João Cartucho Jan 9 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.