Filter by entity type

Hi all.

using the python api: is it possible to perform “find” filtering by entity type (in single entity fields) ?

Example: on the Versions table I want to find all entries linked to any “Asset” entity.

The very ugly way I found is by creating an ‘in’ operator and passing ALL Asset entries to it in the form of:
[
{‘type’: ‘Asset’, ‘id’: 12345},
{‘type’: ‘Asset’, ‘id’: 6789}, …etc
]

…besides ugly that also requires a pre-query to find all items in the relationship entity. Hopefully I’m overlooking something here…

thank you.

2 Likes

Hi there,

I guess the ‘type_is’ operator is what you’re looking for ?

sg.find('Version', [['entity', 'type_is', 'Asset']], ['entity.Asset.code'])

Returns all versions for which the entity is an Asset.
Filters doc, https://developer.shotgunsoftware.com/python-api/reference.html#basic-filters

Cheers

2 Likes

ah of course, how could I miss that !? =)
thank you.

1 Like