2

I want to select Cube.001,Cube.002,Cube.003,Cube.004 at the same time. trying this script

bpy.data.objects["Cube.001","Cube.002","Cube.003","Cube.004"].select_set(state=True)

But is not working. What should i do to select this four objects ?

Avi Aninda
  • 81
  • 2
  • 6

1 Answers1

4

If you want to select all objects at once, then use: bpy.ops.object.select_all(action='SELECT') (select_all operator). In case you want to only select a subset of objects you have to iterate through the list of scene objects (bpy.context.scene.objects) or through the list of objects in the blend-file:

Blender 2.7x

# Deselect all objects
bpy.ops.object.select_all(action='DESELECT')

for o in bpy.data.objects:
    # Check for given object names
    if o.name in ("Cube.026","Cube.027","Cube.028"):
        o.select = True

Blender 2.8x

# Deselect all objects
bpy.ops.object.select_all(action='DESELECT')

for o in bpy.data.objects:
    # Check for given object names
    if o.name in ("Cube.026","Cube.027","Cube.028"):
        o.select_set(True)
brockmann
  • 12,613
  • 4
  • 50
  • 93