Publish_file_type

Hi guys, I am trying ti understand where to get info and how to filter.

pub_files = sg.find(‘PublishedFile’,[ [‘id’, ‘is’, shot[‘id’]], [‘published_file_type’, ‘is’, ‘ma lighting’]],[‘path’] )

so probably this is wrong: [‘published_file_type’, ‘is’, ‘ma lighting’]
And I am wondering where in shotgun can I find the right info for the right filtering?

Thanks.

PublishedFileType is an entity on its own. This means you need to ‘hop’ some fields to get there or give the full dictionary for the entity. Like so:

If you want to filter using some fields inside PublishedFileType

pub_files = sg.find(‘PublishedFile’,
                   [
                         [‘id’, ‘is’, shot[‘id’], 
                         [‘published_file_type.PublishedFileType.code’, ‘is’, ‘ma lighting’]
                   ],
                   [‘path’]
 )

If you want to use the dictionary to query the published file type directly:

pub_files = sg.find(‘PublishedFile’,
                   [
                        [‘id’, ‘is’, shot[‘id’], 
                        [‘published_file_type', ‘is’, {"type": "PublishedFileType", "id": SOME_ID]
                   ], 
                   [‘path’] 
)

Sorry for the formatting.

1 Like

Thanks for your help. :slight_smile: There is also a good way in SG. In configure Columns option, if you show with the cursor on any of the name it show you the sg names, which is good too.

I am not sure if SG website offers some kind of option for developers when they click on “dev” button, it show more helps/options etc… like in Blender. Is something like that in SG web?

There is also the name_is operator to simplify the filter @vtrvtr provided a slight bit.

eg.

[‘published_file_type’, ‘name_is’, ‘ma lighting’]

vs

[‘published_file_type.PublishedFileType.code’, ‘name_is’, ‘ma lighting’]

As far as reference goes… code and code docs are the best bet, but more intuitive links between the knowledge and SG web would be helpful and welcome for developers.
https://developer.shotgridsoftware.com/python-api/reference.html#valid-operators-by-data-type