Query a list of specific asset types from a project

Hi, I am trying to query all assets from a given project, and furthermore list only assets who’s type is defined as “set”. Could anyone advise the best approach to this in terms of filters?

Thanks

Craig

With the Python API?

All assets on a project:

filters = [["project", "is", context.project]]
fields = ["code"]
all_project_assets = shotgun.find("Asset", filters, fields)

All assets of type “Set”:

filters = [["project", "is", context.project], ["sg_asset_type", "is", "set"]]
fields = ["code"]
all_project_assets = shotgun.find("Asset", filters, fields)

Hi Ricardo,

That’s super helpful. Exactly what I was hoping for, cheers.

One further related question you might be able to help me with. I am also trying to return the task name of an asset. Let’s say that I have the asset id and I want to return all the task names. How would I go about that?

I’m trying to get my head around filters and fields, but I’m a little unsure how to go about finding the field names. I tried finding the task name under the configuration fields option but to no avail.

Thanks

Craig

1 Like

You can find the field names from the “Fields” page on the right side menu (click your profile icon when you are admin).

You can also find the field names if you right click the header and go to “Configure Field”. It will list the field codename.

To find all tasks related to one asset:

filters = [["project", "is", context.project], ["entity.Asset.id", "in", [MY_ASSET_ID]]]
fields = ["code"]
all_asset_tasks = shotgun.find("Task", filters, fields)