Assign a different material to objects within dupli_group instances Say you have a cube and a sphere grouped as 'Group'. You instanciate that group and link it to the scene. Now when you click on the instance, there is no material panel.

See the two pictures below for a better understanding of what I'm trying to do.



Is it possible to access the duplicated objects in the dupli instance in order to give them new materials ? 

The only thing I succeeded in doing is to assign a material to an object instance but not to objects within a group instance.

Python answers are welcome.

As requested, here's the code to create a dupli_group instance:

layers = [True] + 19*[False]

# Could replace this with bmesh method
object1 = bpy.ops.surface.primitive_nurbs_surface_sphere_add(radius=1, location=(0, 0, 0), layers=layers)
object1 = bpy.context.active_object

object2 = bpy.ops.mesh.primitive_cube_add(radius=1, location=(4, 0, 0), layers=layers)
object2 = bpy.context.active_object

group = bpy.data.groups.new('some_group_name')
group.objects.link(object1)
group.objects.link(object2)

group_instance = bpy.data.objects.new('some_group_name_instance1', None)
group_instance.dupli_type = 'GROUP'
group_instance.dupli_group = group

bpy.context.scene.objects.link(group_instance)


Then I would expect to have a way to target object1 and object2 within group_instance and to set new materials that won't affect other instances.
Unfortunately, I think it is not possible to do exactly what you want to do.

One of the advantages of using an Empty with dupli_group is that you don't have the overhead of storing much in the way of differences (location, rotation, scale).

If you want to alter the group, you will probably have to instantate objects by copying the data from the group.  There's actually a keyboard shortcut to Make Duplicates Real (Ctrl Shift A) that would work for interactive use.  Since you were using python in your original project here is a small python script I wrote that might accomplish your mission:

import bpy

def mission1(group, scn):

    parent = bpy.data.objects.new("parent", None)
    scn.objects.link(parent)

    for obj in group.objects:
        o2 = obj.copy()
        o2.parent = parent
        for i in range(len(o2.material_slots)):
            ms = o2.material_slots[i]
            ms.link = 'OBJECT'
            ms.material = o2.data.materials[i]
        scn.objects.link(o2)

    return parent
#
#

anchor = mission1(bpy.data.groups["Group"], bpy.context.scene)
anchor.location = [2,0,2]


The parent object is not strictly necessary, but it gives you the ability to manipulate the location and orientation of the group very much like the dupli_group empty you were using before.

An important drawback is that once you have instantiated these copies modifications to the group (adding, removing, relocating objects) will not be propagated.