having trouble selecting grouped objects in inactive layer

Hi all,

I am having trouble selecting grouped objects. I have a number of objects in a group named Group and wanted to select them using

bpy.ops.object.grouped_select()

but that does not result in them becoming selected. Why?

Using

bpy.ops.object.select_same_group(group="Group")

I can select them, but only if the layer they are on is active in the 3D viewport. I would like to be able to put them in an inactive layer and select them from there, but I can’t find out how to do so, so I tried to let the script select the layer containing the group (i.e. the first layer) and then select them like this:

layers = [False] * 20
layers[0] = True
bpy.ops.object.select_same_group(group="Group")


That does not work. Can anyone explain why not?

My goal for this script is to be able to create a few models, put them in a group and then use the script to place them and work on them in sort of the same way a particle system would using the Group option in the Render panel. I often use the particle system this way, usually checking the Use Count, Rotation and Scale options, but I would like to have the ability to partially tweak the results without manually doing so. For instance by selecting a few of the objects and having the script replace them with different ones from the same group, or placing them in a different way.

I would love any tips and suggestions you might have. Thanks!


for ob in bpy.data.groups['Group'].objects:
    ob.select = True

This will select all objects belonging to “Group”.

Finally that works. Thanks BartekSkorupa!