Hi,
does anyone of you have a pointer on how to get to the selected asset(s) in the assetCatalog?
I found that there are python functions to get an entry by providing the asset name but I would like to get the selected items.
thank you very much!
from __future__ import annotations from dataclasses import dataclass from typing import Any import hou @dataclass class UsdAsset: id: str filepath: str name: str data: bytes def get_gallery_pane() -> hou.PythonPanel | None: py_panels: tuple[hou.PythonPanel] = ( pane for pane in hou.ui.paneTabs() if pane.type() == hou.paneTabType.PythonPanel ) return next((pane for pane in py_panels if pane.label() == "Asset Catalog"), None) def gallery_widget() -> Any | None: gallery_pane = get_gallery_pane() if not gallery_pane: return None widget = gallery_pane.activeInterfaceRootWidget()._ag return widget def get_asset(data_source: hou.AssetGalleryDataSource, id: str) -> UsdAsset | None: if not id: return None filepath = data_source.filePath(id) if not filepath: return None return UsdAsset( id=id, filepath=data_source.filePath(id), name=data_source.label(id), data=data_source.blindData(id), ) def get_selected_assets() -> list[UsdAsset]: widget = gallery_widget() if not widget: return [] data_source: hou.AssetGalleryDataSource = hou.ui.sharedLayoutDataSource() selected_ids: list[str] = widget.getSelectedIds() return [get_asset(data_source, asset_id) for asset_id in selected_ids]