Can anyone help me with finding a way to return the publish path of an assets latest published model task in the shotgun api? I can see the path on my project website but can’t seem to get my filters to return the information I need.
3 Likes
Maybe something like this would work for you?
r = sg.find_one("PublishedFile",
[["task.Task.id","is",13151],
["name","is", "alt.ma"]],
fields = ["path"],
order = [{'field_name':'version_number', 'direction':'desc'}])
It’s sorting by version number and returning the first result. You could adjust the filters so that they are more suitable for you.
If for example, you don’t know the id of the model task, but you do know the entity id you could do have:
r = sg.find_one("PublishedFile",
[["task.Task.content","is","Model"],
["entity.Shot.id","is", 1381],
["name","is", "alt.ma"]],
fields = ["path"],
order = [{'field_name':'version_number', 'direction':'desc'}])
3 Likes
Hey Philip thank you so much once again! That helped very much. Just for everyones knowledge here this is what I ended up using.
filters = [
['entity.Asset.code', 'is', asset_name],
['project', 'is', {'type': 'Project', 'id': project_id}],
['task.Task.content', 'is', 'model']
]
fields = ['path']
order = [{'field_name': 'version_number', 'direction': 'desc'}]
path_dict = sg.find_one('PublishedFile', filters, fields, order)
3 Likes
Is there any way to do this in the UI?
ie. just one result, after sorting
This is similar to the “latest”-checkbox for Version entities, but we need it for something else.
2 Likes