user: Show practical ways to work with BoneCollection(bpy_struct) in a Blender add-on or script – include code.

assistant: # BoneCollection(bpy_struct)

base class — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct")

*class* bpy.types.BoneCollection(*bpy_struct*)
:   Bone collection in an Armature data-block

    bones
    :   Bones assigned to this bone collection. In armature edit mode this will always return an empty list of bones, as the bone collection memberships are only synchronized when exiting edit mode.

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Bone`](bpy.types.Bone.html#bpy.types.Bone "bpy.types.Bone"), (readonly)

    child_number
    :   Index of this collection into its parent’s list of children. Note that finding this index requires a scan of all the bone collections, so do access this with care.

        Type:
        :   int in [-inf, inf], default 0

    children
    :   Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`BoneCollection`](#bpy.types.BoneCollection "bpy.types.BoneCollection"), (readonly)

    index
    :   Index of this bone collection in the armature.collections_all array. Note that finding this index requires a scan of all the bone collections, so do access this with care.

        Type:
        :   int in [-inf, inf], default 0, (readonly)

    is_editable
    :   This collection is owned by a local Armature, or was added via a library override in the current blend file

        Type:
        :   boolean, default False, (readonly)

    is_expanded
    :   This bone collection is expanded in the bone collections tree view

        Type:
        :   boolean, default False

    is_local_override
    :   This collection was added via a library override in the current blend file

        Type:
        :   boolean, default False, (readonly)

    is_solo
    :   Show only this bone collection, and others also marked as ‘solo’

        Type:
        :   boolean, default False

    is_visible
    :   Bones in this collection will be visible in pose/object mode

        Type:
        :   boolean, default False

    is_visible_ancestors
    :   True when all of the ancestors of this bone collection are marked as visible; always True for root bone collections

        Type:
        :   boolean, default False, (readonly)

    is_visible_effectively
    :   Whether this bone collection is effectively visible in the viewport. This is True when this bone collection and all of its ancestors are visible, or when it is marked as ‘solo’.

        Type:
        :   boolean, default False, (readonly)

    name
    :   Unique within the Armature

        Type:
        :   string, default “”, (never None)

    parent
    :   Parent bone collection. Note that accessing this requires a scan of all the bone collections to find the parent.

        Type:
        :   [`BoneCollection`](#bpy.types.BoneCollection "bpy.types.BoneCollection")

    bones_recursive
    :   A set of all bones assigned to this bone collection and its child collections.

        (readonly)

    bl_system_properties_get(*\**, *do_create=False*)
    :   DEBUG ONLY. Internal access to runtime-defined RNA data storage, intended solely for testing and debugging purposes. Do not access it in regular scripting work, and in particular, do not assume that it contains writable data

        Parameters:
        :   **do_create** (*boolean**,* *(**optional**)*) – Ensure that system properties are created if they do not exist yet

        Returns:
        :   The system properties root container, or None if there are no system properties stored in this data yet, and its creation was not requested

        Return type:
        :   [`PropertyGroup`](bpy.types.PropertyGroup.html#bpy.types.PropertyGroup "bpy.types.PropertyGroup")

    assign(*bone*)
    :   Assign the given bone to this collection

        Parameters:
        :   **bone** ([`AnyType`](bpy.types.AnyType.html#bpy.types.AnyType "bpy.types.AnyType")) – Bone, PoseBone, or EditBone to assign to this collection

        Returns:
        :   Assigned, Whether the bone was actually assigned; will be false if the bone was already member of the collection

        Return type:
        :   boolean

    unassign(*bone*)
    :   Remove the given bone from this collection

        Parameters:
        :   **bone** ([`AnyType`](bpy.types.AnyType.html#bpy.types.AnyType "bpy.types.AnyType")) – Bone, PoseBone, or EditBone to remove from this collection

        Returns:
        :   Unassigned, Whether the bone was actually removed; will be false if the bone was not a member of the collection to begin with

        Return type:
        :   boolean

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   type