Sub topic 3
The active object versus the selection
This chapter assumes you have Blender installed with the default keymap (left-click select), that you can orbit, pan, and zoom the viewport, and that you know the X, Y, and Z axes. You should also know how to click an object to select it. Here you will learn why Blender tracks two separate things, the selection and the active object, and how that difference changes what your tools do.
Two different ideas
Blender keeps two records of "what you are working on".
- The selection is the set of objects that are selected. It can hold zero, one, or many objects. Selected objects get an orange outline in the viewport.
- The active object is at most one object. It is the one Blender treats as the main target. It gets a lighter, yellow-orange outline.
The active object is usually also selected, but it doesn't have to be. You can deselect everything and Blender will still remember the last active object. The Properties editor keeps showing that object's data even though nothing is highlighted in the viewport.
| Property | Selected objects | Active object |
|---|---|---|
| How many | Zero or more | Zero or one |
| Outline color | Darker orange | Lighter yellow-orange |
| Changed by | Clicking, box select, Select All, and so on | Clicking, or Shift-clicking to extend |
| Shown in Properties editor | No | Yes |
| Used as a reference by some tools | Sometimes | Often |
What the outline colors tell you
In the default theme, the colors work like this:
- A light yellow-orange outline marks the active object.
- A darker orange outline marks other selected objects.
- No outline means the object is not selected. It may still be active, as described above.
Check the colors before you run an operator. If the outline of the object you care about is dark orange, it is selected but not active, and any tool that reads the active object will use a different one.
How the active object is set
Clicking an unselected object selects it and makes it active. Clicking a selected object that is not active makes it active.
To build a multi-object selection, hold Shift and click. The last object you Shift-click becomes the active object. Shift-clicking the active object again deselects it. Shift-clicking a selected, non-active object makes it active without deselecting it.
Box select, circle select, and lasso select add objects to the selection. They do not change which object is active. The next chapter covers those tools.
Why the difference matters
Transforms act on every selected object
G, R, and S move, rotate, and scale all selected objects together. The active object does not take priority here. If you select a lamp and a cube and press G, both move.
Some tools use the active object as the reference
Several operations treat the active object differently from the rest of the selection.
- Join (Ctrl+J) merges the selected meshes into the active one. The result keeps the active object's name, origin, and materials.
- Parenting (Ctrl+P) makes the active object the parent of the other selected objects.
- Copy Attributes and similar add-on operators copy from the active object to the others.
- Modifier and constraint targets are often set by the active object.
- Alt-editing a property, such as holding Alt while changing a value, applies the change to every selected object.
- The Properties editor and the Transform panel (N key) always display the active object's values.
Because of the last item, the Transform panel can mislead you. If five objects are selected and you type a new X location into the panel, only the active object changes, unless you hold Alt while editing the field.
The Outliner shows the same state
In the Outliner, selected objects have a highlighted row. The active object has a brighter highlight. Clicking a row selects that object and makes it active. Ctrl-click extends the selection, and the clicked row becomes active.
Inspecting the state with Python
You can read the same two records from Python. bpy.context.active_object is the active object, and bpy.context.selected_objects is the list of selected objects. The following script reports both.
import bpy
active = bpy.context.active_object
selected = bpy.context.selected_objects
print("Active:", active.name if active else None)
print("Selected:", [o.name for o in selected])
print("Active is selected:", active in selected if active else False)Run it from the Scripting workspace's Text Editor. Try it in three situations: nothing selected, one object selected, and several objects selected with one Shift-clicked last. In the last case, the active object is the one you clicked last.
To set both explicitly, use select_set and the view layer:
import bpy
bpy.ops.object.select_all(action='DESELECT')
obj = bpy.data.objects.get('Cube')
if obj is not None:
obj.select_set(True)
bpy.context.view_layer.objects.active = objSelecting and activating are separate calls. select_set(True) adds the object to the selection. Assigning to view_layer.objects.active changes the active object. If you do only the first, the object is highlighted but the Properties editor still shows the previous active object. If you do only the second, the object is active but not selected.
Common errors
- Typing into the Transform panel and only one object moves. The panel edits the active object only. Hold Alt while editing to apply the value to all selected objects, or use G, R, and S.
- Join keeps the wrong name or materials. The active object is the target. Shift-click the object you want to keep last, then press Ctrl+J.
- Parenting is reversed. The active object becomes the parent. Select the children first, then Shift-click the parent last.
- A script fails with
AttributeError: 'NoneType' object has no attribute 'name'. No object is active. Checkbpy.context.active_objectforNonebefore using it. - A script acts on the wrong objects.
bpy.context.active_objectcan be an object that is not selected. If you need selected objects, checkobj.select_get()or usebpy.context.selected_objects. - Hidden objects. Hidden objects cannot be selected. An object can also be unselectable if it is disabled for selection in the Outliner filter. If a click does nothing, check the Outliner.
Putting it together
A reliable habit is to select everything you want to affect, then make the reference object active last by Shift-clicking it. For transforms this ordering doesn't matter, but for joining, parenting, and the Transform panel it decides which object the operation uses.
Exercise
You select a cube, then Shift-click a sphere, then Shift-click a cone. You press Ctrl+P and choose Object. Which object becomes the parent, and which objects become children? Then you press N and type a new Z location. Which objects move?
Show answer
The cone is the active object because it was Shift-clicked last, so it becomes the parent. The cube and the sphere become its children. The Transform panel edits the active object only, so only the cone's Z location changes. The children follow because they are parented to it. Holding Alt while editing would apply the value to every selected object instead.
Exercise
Write a Python snippet that makes the object named 'Sphere' the only selected object and also the active object. What happens if you leave out the last line?
Show answer
import bpy bpy.ops.object.selectall(action='DESELECT') obj = bpy.data.objects['Sphere'] obj.selectset(True) bpy.context.view_layer.objects.active = obj Without the last line, the sphere is selected but the previously active object stays active, so the Properties editor and the Transform panel keep showing the old object.