Hi there!
I’m working on an addon that have a button running a custom operator, which requires to hase at least a bone selected.
So while working on detecting whether bones or objects are detected, I noticed that, even after clicking an empty space or using the Select None operator, the API still returns “something” when asked about what’s selected/active:
In Object mode:
>>> C.object
bpy.data.objects['Armature']
>>> C.active_object
bpy.data.objects['Armature']
In Pose mode:
>>> C.selected_pose_bones
[]
>>> C.active_pose_bone
bpy.data.objects['Armature'].pose.bones["Bone"]
To be clear, I managed to get my things working as I wanted
@classmethod
def poll(cls, context):
return context.selected_pose_bones
But I have the impression that I can get around this issue this time only because I happen to only need a selected bone ;
But if I had to work with object selection, or with active selection, to me it looks like it wouldn’t work, at least not this way?
I know that selection and active are independent, and you can have either one without the other, but it seems weird that even after making sure to “deselect all”, the API seems to consider there is still something selected. Is that even normal?
Or maybe it would require me to make a custom script that forces Blender to clear out selection/active, but that sounds like a terrible solution for the user if using Blender’s “Select None” doesn’t actually do as it says.