Providing color feedback
Our object list will be much more useful if we can highlight which objects are selected and which are active. For instance, to reflect the selection status of an object in the color of its name, our script must perform two actions:
- Check whether an object is selected.
- If it’s selected or active, display its name in a different color.
Let’s learn how to perform these tasks using Blender’s API.
Checking whether an object has been selected
We can get the selection status of an object using its select_get()
method. For instance, if the 'Cube'
object is selected, its selected_get
method will return True
:
>>> import bpy >>> bpy.data.objects['Cube'].select_get() True
We already know from Chapter 2, that, unlike the selection status, active
is not a flag of the object, so how we retrieve this information is a bit different.
Checking whether an object is active
To check whether...