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

assistant: # AssetShelf(bpy_struct)

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

subclasses —
[`IMAGE_AST_brush_paint`](bpy.types.IMAGE_AST_brush_paint.html#bpy.types.IMAGE_AST_brush_paint "bpy.types.IMAGE_AST_brush_paint"), [`NODE_AST_compositor`](bpy.types.NODE_AST_compositor.html#bpy.types.NODE_AST_compositor "bpy.types.NODE_AST_compositor"), [`VIEW3D_AST_brush_gpencil_paint`](bpy.types.VIEW3D_AST_brush_gpencil_paint.html#bpy.types.VIEW3D_AST_brush_gpencil_paint "bpy.types.VIEW3D_AST_brush_gpencil_paint"), [`VIEW3D_AST_brush_gpencil_sculpt`](bpy.types.VIEW3D_AST_brush_gpencil_sculpt.html#bpy.types.VIEW3D_AST_brush_gpencil_sculpt "bpy.types.VIEW3D_AST_brush_gpencil_sculpt"), [`VIEW3D_AST_brush_gpencil_vertex`](bpy.types.VIEW3D_AST_brush_gpencil_vertex.html#bpy.types.VIEW3D_AST_brush_gpencil_vertex "bpy.types.VIEW3D_AST_brush_gpencil_vertex"), [`VIEW3D_AST_brush_gpencil_weight`](bpy.types.VIEW3D_AST_brush_gpencil_weight.html#bpy.types.VIEW3D_AST_brush_gpencil_weight "bpy.types.VIEW3D_AST_brush_gpencil_weight"), [`VIEW3D_AST_brush_sculpt`](bpy.types.VIEW3D_AST_brush_sculpt.html#bpy.types.VIEW3D_AST_brush_sculpt "bpy.types.VIEW3D_AST_brush_sculpt"), [`VIEW3D_AST_brush_sculpt_curves`](bpy.types.VIEW3D_AST_brush_sculpt_curves.html#bpy.types.VIEW3D_AST_brush_sculpt_curves "bpy.types.VIEW3D_AST_brush_sculpt_curves"), [`VIEW3D_AST_brush_texture_paint`](bpy.types.VIEW3D_AST_brush_texture_paint.html#bpy.types.VIEW3D_AST_brush_texture_paint "bpy.types.VIEW3D_AST_brush_texture_paint"), [`VIEW3D_AST_brush_vertex_paint`](bpy.types.VIEW3D_AST_brush_vertex_paint.html#bpy.types.VIEW3D_AST_brush_vertex_paint "bpy.types.VIEW3D_AST_brush_vertex_paint"), [`VIEW3D_AST_brush_weight_paint`](bpy.types.VIEW3D_AST_brush_weight_paint.html#bpy.types.VIEW3D_AST_brush_weight_paint "bpy.types.VIEW3D_AST_brush_weight_paint"), [`VIEW3D_AST_pose_library`](bpy.types.VIEW3D_AST_pose_library.html#bpy.types.VIEW3D_AST_pose_library "bpy.types.VIEW3D_AST_pose_library")

*class* bpy.types.AssetShelf(*bpy_struct*)
:   Regions for quick access to assets

    asset_library_reference
    :   Choose the asset library to display assets from

        - `ALL`
          All Libraries – Show assets from all of the listed asset libraries.
        - `LOCAL`
          Current File – Show the assets currently available in this Blender session.
        - `ESSENTIALS`
          Essentials – Show the basic building blocks and utilities coming with Blender.
        - `CUSTOM`
          Custom – Show assets from the asset libraries configured in the Preferences.

        Type:
        :   enum in [`'ALL'`, `'LOCAL'`, `'ESSENTIALS'`, `'CUSTOM'`], default `'ALL'`

    bl_activate_operator
    :   Operator to call when activating an item with asset reference properties

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

    bl_default_preview_size
    :   Default size of the asset preview thumbnails in pixels

        Type:
        :   int in [32, 256], default 0

    bl_drag_operator
    :   Operator to call when dragging an item with asset reference properties

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

    bl_idname
    :   If this is set, the asset gets a custom ID, otherwise it takes the name of the class used to define the asset (for example, if the class name is “OBJECT_AST_hello”, and bl_idname is not set by the script, then bl_idname = “OBJECT_AST_hello”)

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

    bl_options
    :   Options for this asset shelf type

        - `NO_ASSET_DRAG`
          No Asset Dragging – Disable the default asset dragging on drag events. Useful for implementing custom dragging via custom key-map items..
        - `DEFAULT_VISIBLE`
          Visible by Default – Unhide the asset shelf when it’s available for the first time, otherwise it will be hidden.
        - `STORE_ENABLED_CATALOGS_IN_PREFERENCES`
          Store Enabled Catalogs in Preferences – Store the shelf’s enabled catalogs in the preferences rather than the local asset shelf settings.
        - `ACTIVATE_FOR_CONTEXT_MENU`
          When spawning a context menu for an asset, activate the asset and call `bl_activate_operator` if present, rather than just highlighting the asset.

        Type:
        :   enum set in {`'NO_ASSET_DRAG'`, `'DEFAULT_VISIBLE'`, `'STORE_ENABLED_CATALOGS_IN_PREFERENCES'`, `'ACTIVATE_FOR_CONTEXT_MENU'`}, default set()

    bl_space_type
    :   The space where the asset shelf will show up in. Ignored for popup asset shelves which can be displayed in any space.

        Type:
        :   enum in [Space Type Items](bpy_types_enum_items/space_type_items.html#rna-enum-space-type-items), default `'EMPTY'`

    filter_action
    :   Show Action data-blocks

        Type:
        :   boolean, default False

    filter_annotations
    :   Show Annotation data-blocks

        Type:
        :   boolean, default False

    filter_armature
    :   Show Armature data-blocks

        Type:
        :   boolean, default False

    filter_brush
    :   Show Brushes data-blocks

        Type:
        :   boolean, default False

    filter_cachefile
    :   Show Cache File data-blocks

        Type:
        :   boolean, default False

    filter_camera
    :   Show Camera data-blocks

        Type:
        :   boolean, default False

    filter_curve
    :   Show Curve data-blocks

        Type:
        :   boolean, default False

    filter_curves
    :   Show/hide Curves data-blocks

        Type:
        :   boolean, default False

    filter_font
    :   Show Font data-blocks

        Type:
        :   boolean, default False

    filter_grease_pencil
    :   Show Grease Pencil data-blocks

        Type:
        :   boolean, default False

    filter_group
    :   Show Collection data-blocks

        Type:
        :   boolean, default False

    filter_image
    :   Show Image data-blocks

        Type:
        :   boolean, default False

    filter_lattice
    :   Show Lattice data-blocks

        Type:
        :   boolean, default False

    filter_light
    :   Show Light data-blocks

        Type:
        :   boolean, default False

    filter_light_probe
    :   Show Light Probe data-blocks

        Type:
        :   boolean, default False

    filter_linestyle
    :   Show Freestyle’s Line Style data-blocks

        Type:
        :   boolean, default False

    filter_mask
    :   Show Mask data-blocks

        Type:
        :   boolean, default False

    filter_material
    :   Show Material data-blocks

        Type:
        :   boolean, default False

    filter_mesh
    :   Show Mesh data-blocks

        Type:
        :   boolean, default False

    filter_metaball
    :   Show Metaball data-blocks

        Type:
        :   boolean, default False

    filter_movie_clip
    :   Show Movie Clip data-blocks

        Type:
        :   boolean, default False

    filter_node_tree
    :   Show Node Tree data-blocks

        Type:
        :   boolean, default False

    filter_object
    :   Show Object data-blocks

        Type:
        :   boolean, default False

    filter_paint_curve
    :   Show Paint Curve data-blocks

        Type:
        :   boolean, default False

    filter_palette
    :   Show Palette data-blocks

        Type:
        :   boolean, default False

    filter_particle_settings
    :   Show Particle Settings data-blocks

        Type:
        :   boolean, default False

    filter_pointcloud
    :   Show/hide Point Cloud data-blocks

        Type:
        :   boolean, default False

    filter_scene
    :   Show Scene data-blocks

        Type:
        :   boolean, default False

    filter_sound
    :   Show Sound data-blocks

        Type:
        :   boolean, default False

    filter_speaker
    :   Show Speaker data-blocks

        Type:
        :   boolean, default False

    filter_text
    :   Show Text data-blocks

        Type:
        :   boolean, default False

    filter_texture
    :   Show Texture data-blocks

        Type:
        :   boolean, default False

    filter_volume
    :   Show/hide Volume data-blocks

        Type:
        :   boolean, default False

    filter_work_space
    :   Show workspace data-blocks

        Type:
        :   boolean, default False

    filter_world
    :   Show World data-blocks

        Type:
        :   boolean, default False

    preview_size
    :   Size of the asset preview thumbnails in pixels

        Type:
        :   int in [32, 256], default 0

    search_filter
    :   Filter assets by name

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

    show_names
    :   Show the asset name together with the preview. Otherwise only the preview will be visible.

        Type:
        :   boolean, default False

    *classmethod* poll(*context*)
    :   If this method returns a non-null output, the asset shelf will be visible

        Return type:
        :   boolean

    *classmethod* asset_poll(*asset*)
    :   Determine if an asset should be visible in the asset shelf. If this method returns a non-null output, the asset will be visible.

        Return type:
        :   boolean

    *classmethod* get_active_asset()
    :   Return a reference to the asset that should be highlighted as active in the asset shelf

        Returns:
        :   The weak reference to the asset to be highlighted as active, or None

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

    *classmethod* draw_context_menu(*context*, *asset*, *layout*)
    :   Draw UI elements into the context menu UI layout displayed on right click

    *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