0
$\begingroup$

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 ?

| improve this question | | | | |
$\endgroup$
2
$\begingroup$

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)
| improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Write the code for me replacing the old one . I am finding it hard. $\endgroup$ – Avi Aninda Sep 5 '19 at 9:48
  • $\begingroup$ Below code is workinf fine but i want something like mine one .. for o in ("Cube.026", "Cube.027","Cube.028","Cube.029","Cube.030","Cube.031"): obj = bpy.context.scene.objects.get(o) if obj: obj.select_set(True) $\endgroup$ – Avi Aninda Sep 5 '19 at 9:50
  • $\begingroup$ see edit above for code $\endgroup$ – Gabriel Rohweder Sep 5 '19 at 19:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.