After I post this question I think I can have a look at
the implementation(f51a3aedc9540e0bcda4f16deec22e9aa722ef24
) for answer.
Firstly, active_object
and object
refer to the same object when you
try to access either one of them.
The attribute retrieving happens in the function ed_screen_context
(file screen_context.c
).
This function performs string matching on the attribute names.
For active_object
and object
you can see both of their implementations return obact
(It is scene->basact
actually) as result.
Secondly, when you set an active object through scene.active = ...
,
active_object
and object
are assigned by that object.
The call chain of this process is
SceneObjects_active_set
(file rna_scene_gen.c
) -> rna_Scene_active_object_set
(file rna_scene.c
).
In the function rna_Scene_active_object_set
you can see the active object is assigned to scene->basact
.
Finally, selected_objects
seems to be a totally different thing from active_object
and object
.
The selecting of an object happens in function Object_select_set
(file rna_object_gen.c
). But I failed to find the relation between active_object
and selected_objects
as @sambler said.
EDIT: The relation between selected_objects
and active_object
/object
is confirmed.
as @sambler said
while manually selecting the last addition will be the active object, so active_object is rarely the first in the selected_objects list
A selecting triggered by manual action happen in a space operator, rather than in a Python script binding.
So I search this operator in view3d
space.
I found the operator VIEW3D_OT_select
in file view3d_select.c
.
And there is a call chain of
view3d_select_exec
-> mouse_select
-> ED_base_object_activate
.
I see the object activation happens in ED_base_object_activate
:
if ((oldbasact != basact) && (is_obedit == false)) {
ED_base_object_activate(C, basact); /* adds notifier */
}
Therefore the last selection will be the new active object.