[BPY:] Adding a group instance

Let’s say I have a group, called, very originally “Group”
It’s got some objects in it.
How can I make an instance of this group from bpy and place it at a certain location?
Something like:


groupToAdd = bpy.data.groups["Group"]
bpy.data.addInstance(groupToAdd, location)

I’ve hunted through google and the API and haven’t found anything

The simplest way is to create an Empty, activate the dupligroup feature and assign your group to it.


import bpy
ob_mt = bpy.data.objects.new("mt_dupe",None)
bpy.data.scenes[0].objects.link(ob_mt)
ob_mt.dupli_type = 'GROUP'
grp = bpy.data.groups[0]    #Assume our group is the first one.
ob_mt.dupli_group = grp

Add an object to a group and give this a try.

Or use the op


context = bpy.context
bpy.ops.object.group_instance_add(group="Group", location=(1,2,3))
empty = context.object