Selecting an object via scripting? As shown below, I have 2 nested spheres, each with a different material (inner = &quot;1&quot;, outer = &quot;2&quot;). Ultimately, I need to select the inner sphere (material &quot;1&quot;) via python scripting.
I've found a number of ways to select (or make active) one of the spheres. However, even though Blender says that it's selecting the correct sphere (indicated by orange line around center sphere), I don't believe it's active -- adding a modifier applies it to the outer sphere instead. That, and the material properties show the properties of the outer sphere.
bpy.data.objects['Sphere.017']


refers to an object. (Lets assume all names in quotes are the names of objects in your Blender Scene)

2.8 Recent Version of the API

bpy.data.objects["Cube"].select_set(True)

# to select the object in the 3D viewport,
# this way you can also select multiple objects

bpy.context.view_layer.objects.active = bpy.data.objects['Sphere']
# to set the active object




https://docs.blender.org/api/current/bpy.types.LayerObjects.html#bpy.types.LayerObjects



⚠Older Version of API 2.79

A python script can do something with that.

You can also use

bpy.data.objects['Cube'].select = True
# to select the object in the 3D viewport,
# this way you can also select multiple objects

# additionally you can use
bpy.context.scene.objects.active = bpy.data.objects['Sphere.017']
# to make it the active selected object