I would like to select objects which are on a specific layer AND in a certain group at the same time.
How could I do that?
I only found bpy.ops.object.select_grouped(), where I can define 1 selection criterion.
Many thanks for help!
I would like to select objects which are on a specific layer AND in a certain group at the same time.
How could I do that?
I only found bpy.ops.object.select_grouped(), where I can define 1 selection criterion.
Many thanks for help!
import bpy
grp = bpy.data.groups["Group"]
layer_num = 0
sce = bpy.context.scene
# Deselect everything
bpy.ops.object.select_all(action='DESELECT')
# Enable target layer (optional)
sce.layers = [False] * 20
sce.layers[layer_num] = True
found = False
for ob in grp.objects:
if ob.layers[layer_num]:
print(ob.name)
ob.select = True
# Make one object active
if not found:
found = True
sce.objects.active = ob