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

assistant: # Collection(ID)

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`ID`](bpy.types.ID.html#bpy.types.ID "bpy.types.ID")

*class* bpy.types.Collection(*ID*)
:   Collection of Object data-blocks

    active_exporter_index
    :   Active index in the exporters list

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

    all_objects
    :   Objects that are in this collection and its child collections

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

    children
    :   Collections that are immediate children of this collection

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

    collection_children
    :   Children collections with their parent-collection-specific settings

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

    collection_objects
    :   Objects of the collection with their parent-collection-specific settings

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

    color_tag
    :   Color tag for a collection

        Type:
        :   enum in [Collection Color Items](bpy_types_enum_items/collection_color_items.html#rna-enum-collection-color-items), default `'COLOR_01'`

    exporters
    :   Export Handlers configured for the collection

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

    hide_render
    :   Globally disable in renders

        Type:
        :   boolean, default False

    hide_select
    :   Disable selection in viewport

        Type:
        :   boolean, default False

    hide_viewport
    :   Globally disable in viewports

        Type:
        :   boolean, default False

    instance_offset
    :   Offset from the origin to use when instancing

        Type:
        :   [`mathutils.Vector`](mathutils.html#mathutils.Vector "mathutils.Vector") of 3 items in [-inf, inf], default (0.0, 0.0, 0.0)

    lineart_intersection_mask
    :   Intersection generated by this collection will have this mask value

        Type:
        :   boolean array of 8 items, default (False, False, False, False, False, False, False, False)

    lineart_intersection_priority
    :   The intersection line will be included into the object with the higher intersection priority value

        Type:
        :   int in [0, 255], default 0

    lineart_usage
    :   How to use this collection in Line Art calculation

        - `INCLUDE`
          Include – Generate feature lines for this collection.
        - `OCCLUSION_ONLY`
          Occlusion Only – Only use the collection to produce occlusion.
        - `EXCLUDE`
          Exclude – Don’t use this collection in Line Art.
        - `INTERSECTION_ONLY`
          Intersection Only – Only generate intersection lines for this collection.
        - `NO_INTERSECTION`
          No Intersection – Include this collection but do not generate intersection lines.
        - `FORCE_INTERSECTION`
          Force Intersection – Generate intersection lines even with objects that disabled intersection.

        Type:
        :   enum in [`'INCLUDE'`, `'OCCLUSION_ONLY'`, `'EXCLUDE'`, `'INTERSECTION_ONLY'`, `'NO_INTERSECTION'`, `'FORCE_INTERSECTION'`], default `'INCLUDE'`

    lineart_use_intersection_mask
    :   Use custom intersection mask for faces in this collection

        Type:
        :   boolean, default False

    objects
    :   Objects that are directly in this collection

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

    use_lineart_intersection_priority
    :   Assign intersection priority value for this collection

        Type:
        :   boolean, default False

    children_recursive
    :   A list of all children from this collection.

        Type:
        :   list of [`Collection`](#bpy.types.Collection "bpy.types.Collection")

        (readonly)

    users_dupli_group
    :   The collection instance objects this collection is used in

        Type:
        :   tuple of [`Object`](bpy.types.Object.html#bpy.types.Object "bpy.types.Object")

        (readonly)

    *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