Blender 4.0+
Blender 4.0 introduces bpy.types.AssetRepresentation, bpy.context.selected_assets, bpy.context.asset we can use to our advantage.
import bpy class PrintSelectedAssets(bpy.types.Operator): bl_idname = "asset.print_selected_assets" bl_label = "Print Selected Assets" @classmethod def poll(cls, context): return context.selected_assets def execute(self, context): for asset_representation in context.selected_assets: print(f"{asset_representation.full_path=}") print(f"{asset_representation.full_library_path=}") print(f"{asset_representation.id_type=}") print(f"{asset_representation.name=}") # This will be None if the asset is not located in current file : print(f"{asset_representation.local_id=}") print(context.asset) # Active asset return {"FINISHED"} def display_button(self, context): self.layout.operator(PrintSelectedAssets.bl_idname) def register(): bpy.utils.register_class(PrintSelectedAssets) bpy.types.ASSETBROWSER_MT_editor_menus.append(display_button) def unregister(): bpy.types.ASSETBROWSER_MT_editor_menus.remove(display_button) bpy.utils.unregister_class(PrintSelectedAssets) if __name__ == "__main__": register()