Using filters to fetch shots

Hi,
Below is the filter I have used to fetch all the shots of a particular sequence of a project which have a particular asset in them.
CODE :
filters = [
[‘project’, ‘is’, {‘type’: ‘Project’, ‘id’: proj[‘id’]}],
[‘sg_sequence’, ‘is’, {‘type’: ‘Sequence’, ‘id’: 29}],
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘id’: assetToFind[‘id’]}]
]
where I have already got proj[‘id’] and assetToFind[‘id’] from the UI of my tool.
Now I need to fetch all those shots which have any of the asset within a given list.
filters = [
[‘project’, ‘is’, {‘type’: ‘Project’, ‘id’: proj[‘id’]}],
[‘sg_sequence’, ‘is’, {‘type’: ‘Sequence’, ‘id’: 29}],
<list_of_assets>
]

Hi,
Just found a “filter_operator” solution and it worked …
Code :
filters = [
[‘project’, ‘is’, {‘type’: ‘Project’, ‘id’: 70}],
{
‘filter_operator’: ‘any’,
‘filters’ : [
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘id’: 1288}],
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘id’: 1230}],
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘id’: 1234}]
]
}
]
But still it would be great if I can use “code” instead of “id” as below :
filters = [
[‘project’, ‘is’, {‘type’: ‘Project’, ‘id’: 70}],
{
‘filter_operator’: ‘any’,
‘filters’ : [
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘code’: ‘Acorn’}],
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘code’: ‘Bunny’}],
[‘assets’, ‘is’, {‘type’: ‘Asset’, ‘code’: ‘Flash’}]
]
}
]
When changed the code like above it gave me following error :
shotgun_api3.shotgun.Fault: API read() invalid/missing entity hash integer ‘id’:
{“type”=>“Asset”, “code”=>“Acorn”}

1 Like