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!
Asset Gallery / Asset Catalog: HOM methods
204 2 0-
- mrtn
- Member
- 6 posts
- Joined: Jan. 2015
- Offline
-
- elovikov
- Member
- 154 posts
- Joined: June 2019
- Offline
i'm not aware of public api but here is the script i'm using
get_selected_asset would return anything selected in the widget (multi-select is supported)
data bytes is a blob from asset database, currently it used by solaris to determine variant of the asset so on insertion to stage it can set the variant for the asset
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]
get_selected_asset would return anything selected in the widget (multi-select is supported)
data bytes is a blob from asset database, currently it used by solaris to determine variant of the asset so on insertion to stage it can set the variant for the asset
-
- mrtn
- Member
- 6 posts
- Joined: Jan. 2015
- Offline
-
- Quick Links

