2.5 Add An Object To A Group (without using bpy.ops)

Hi All,

I am trying to figure out how to add an object to a group without using bpy.ops.

Here is what I have:


ob = bpy.data.objects["Cube"]
grp = bpy.data.groups["myGroup"]
grp.objects.append(ob)

The API says that the group contains a collection of objects, but when I try to append, I get a message that the append attribute does not exist. If it truly is a python collection shouldn’t I be able to append to it?

Does anyone know how to add an object to an existing group?

Thanks

Ah, it is link, not append.


ob = bpy.data.objects["Cube"]
grp = bpy.data.groups["myGroup"]
grp.objects.link(ob)

not too sure, but I think…


grp.objects.link(ob)

P.S. Found by:


print(dir(grp.objects))