Is there a a way to query a unique list of tags used by the assets within a given project?
Is this the best way to do it??
# Example: Get all tags for assets in project
sg = ShotgunUtils.createConnection()
result = sg.summarize(entity_type='Asset',
filters=[
['project', 'is', {'type': 'Project', 'id': 583}]
],
summary_fields=[{'field':'id', 'type':'count'}],
grouping=[{'field': 'tags', 'type': 'exact', 'direction': 'asc'}]
)
from pprint import pprint
tags = [x['group_name'] for x in result['groups']]
print tags
1 Like
Does anyone have any feedback on this?
Looks good to me. Does it work as expected?
Please please use print(tags)
to be py3 compatible
2 Likes
Hi I’m sorry, no one responded sooner.
I agree with @mmoshev though, I think what you’ve got there is what I would have done as well.
1 Like
I’ve never used ShotgunUtils. I’ve read about it and I assume you use this instead shotgun_api3 because you’re within an app. If it’s not the reason, I’m curious to know why!
However, I would have done the same with shotgun_api3.
ShotgunUtils is just a custom python module I’ve written. it doesn’t do anything specific other than handle connections to shotgun.
1 Like