Animationem

Animationem

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Python Asset Gallery Data Source Issue March 31, 2024, 10:56 p.m.

AAaronLi
I used the software DB Browser for SQLite to view the db database and found that thumbnail is a BLOB type, not a file path. I used the following code to successfully generate assets with thumbnails, I hope it can help you.
ag = hou.AssetGalleryDataSource("H:/library/houdini/assetGallery.db")


def open_image_as_bytes(file_path):
    with open(file_path, 'rb') as f:
        return f.read()

label = 'Baskets'
filepath = 'H:/library/meshusd/Baskets/Baskets_main.usda'
thumbpath = 'H:/library/meshusd/Baskets/thumbnail.png'

ag.addItem(label, filepath, open_image_as_bytes(thumbpath))

ag.saveAs('H:/library/houdini/assetGallery.db')


Hey AAronLi! Sorry for getting back to this so late, I wasn't notified I got a response. This worked like a charm, thanks so much!

Python Asset Gallery Data Source Issue Jan. 4, 2024, 7:55 p.m.

Hello!

I'm trying to expand on a tool I created a couple of months ago by adding a selected list of assets to the Layout Asset Gallery via Python. I've pretty much gotten everything down except for the thumbnail portion of this code snippet:

(This is an example code)

import hou

ag = hou.AssetGalleryDataSource('C:\\Users\\joeshmoe\\Desktop\\test.db')

label = 'Sphere'
file = 'C:\\Users\\joeshmoe\\Desktop\\sphere.abc'
thumbnail = b'C:\\Users\\joeshmoe\\Desktop\\sphere.jpg'

ag.addItem(label, file, thumbnail)

ag.saveAs('C:\\Users\\joeshmoe\\Desktop\\test.db')

When I reload the .db file the asset does show up in my gallery, however there is no thumbnail like you would anticipate. The path and label are all populated but not the thumbnail. It's wanting the path converted to bytes in the string but I'm not sure why.

Is there something I'm doing incorrectly or is there something I need to add?

While I'm here, is there any way of refreshing/reloading the Layout Asset Gallery pane tab with python? It doesn't automatically populate the gallery when I use the script so I'm wondering if I can just reload the db file with some code.

Thanks!

Network Editor Right-Side Button Menu April 6, 2023, 9:23 p.m.

Hello!

I was wondering if anyone knew where I could find the file that allows for the menu placement of these buttons here on the network editor? I've been looking through most of the folders and .xml files but I can't seem to find it. The closest I got was the NetworkViewMenu.xml file but those are only for the menu on the left.

I would like to add a button to this list (icon and everything) that runs a specific script.

Any help is appreciated, Thanks!