diff --git a/scripts/startup/bl_operators/anim.py b/scripts/startup/bl_operators/anim.py index 309b88fadc9..9846b8e2010 100644 --- a/scripts/startup/bl_operators/anim.py +++ b/scripts/startup/bl_operators/anim.py @@ -525,9 +525,16 @@ class ARMATURE_OT_copy_bone_color_to_selected(Operator): class ARMATURE_OT_collection_solo_visibility(Operator): - """Hide all other bone collections and show the active one""" + """Hide all other bone collections and show the active one. + + Note that it is necessary to also show the ancestors of the active bone + collection in order to ensure its visibility. + """ bl_idname = "armature.collection_solo_visibility" bl_label = "Solo Visibility" + bl_description = "Hide all other bone collections and show the active one. " + \ + "Note that it is necessary to also show the ancestors of the active " + \ + "bone collection in order to ensure its visibility" bl_options = {'REGISTER', 'UNDO'} name: StringProperty(name='Bone Collection') @@ -538,8 +545,29 @@ class ARMATURE_OT_collection_solo_visibility(Operator): def execute(self, context): arm = context.object.data - for bcoll in arm.collections: - bcoll.is_visible = bcoll.name == self.name + + # Find the named bone collection. + if self.name: + try: + solo_bcoll = arm.collections[self.name] + except KeyError: + self.report({'ERROR'}, "Bone collection %r not found" % self.name) + return {'CANCELLED'} + else: + solo_bcoll = arm.collections.active + if not solo_bcoll: + self.report({'ERROR'}, "Armature has no active Bone collection, nothing to solo") + return {'CANCELLED'} + + # Hide everything first. + for bcoll in arm.collections.all: + bcoll.is_visible = False + + # Show the named bone collection and all its ancestors. + while solo_bcoll: + solo_bcoll.is_visible = True + solo_bcoll = solo_bcoll.parent + return {'FINISHED'}