This module contains scriptable methods for manipulating the Asset Gallery database.
To programmatically add items to the Asset Gallery database you would need only provide a display name, the path to the asset and an image to be used as the asset’s thumbnail.
A simple script for making a new database and adding an asset would look like this:
import hou from Pyside2 import QtGui # set the db file to be something specific hou.qt.AssetGallery.setAssetDBFile("d:/myproject/MyProject_AssetGalleryDb.db") # read in the thumbnail thumbnail_path = "d:/assets/newasset1/newasset1.png" thumbnail = QtGui.QImage() thumbnail.load(thumbnail_path) # add the database entry item_uuid = hou.qt.AssetGallery.addAsset( "new asset 1", "d:/assets/newasset1/newasset1.usd", thumbnail) print("new asset uuid:", item_uuid)
The database does not store the asset directly, it only stores the path to it. The thumbnail, though, is stored directly in the database. If the thumbnail file later changes on disk, that change will not be reflected in the Asset Gallery database.
Create a new
Optional, set the widget’s parent to
addAsset(name, path, thumbnail, thumbnailpath = None)
Add a new asset to the gallery.
Returns a UUID for the new asset.
The path to the asset on disk.
A Qimage to be used as the asset’s thumbnail image.
optional, the path to the original thumbnail image. This is stored stored as metadata for later reference only.
Remove the specified asset.
Set the name of the asset specified by
Set the filepath of the asset specified by
setAssetThumbnail(item_uuid, thumbnail, thumbnailpath=None)
Set the thumbnail of the asset specified by
item_uuid to the QImage
thumbnail. Optionally save
thumbnailpath in the asset’s metadat to make not of the source path for the thumbnail.
Get the name of the asset specified by
Get the filepath of the asset specified by
Get the thumbnail as a QImage of the asset specified by
Point the Asset Galleries to a different local database file specified by
HOUDINI_ASSETGALLERY_DB_FILE. When this is set with this function, this location will also be saved into the current .hip file and restored when it is loaded.
filepath can contain variables which will be expanded when the database is loaded.
filepath is empty or None, then Asset Galleries will perform a search for the database file accourding to
HOUDINI_ASSETGALLERY_DB_FILE. This will also stop the database file location from being restored when this .hip file is loaded.