For blender4.0
There seems to have been a change in the API. The following are the changes
From selected_asset_files
To selected_assets
https://docs.blender.org/api/current/bpy.context.html#bpy.context.selected_assets
import bpy from pathlib import Path 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 in context.selected_assets: asset_path=asset.full_path print("### asset :",asset_path) 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(): for f in bpy.types.ASSETBROWSER_MT_editor_menus._dyn_ui_initialize(): if f.__name__ == display_button.__name__: bpy.types.ASSETBROWSER_MT_editor_menus.remove(f) return if __name__ == "__main__": unregister() register() 


