Open omac777 opened 1 year ago
Hello, You just need to add ‘episode.Episode.name’ and ‘project.Project.name’ to the list of fields to retrieve, if I understood what you’re after. Something like: ['code', ‘sg_sequence.Sequence.sg_status_list’, ‘episode.Episode.name’, ‘project.Project.name’ ] Hope it helps.
On 13 Dec 2022, at 14:21, David Marceau @.***> wrote:
Using the following variables:
project_name = 'SuperStickman' episode_name = 'Stic-101' I want to extract ALL the Project, Episode and Shot fields together.
I tried these two different ways, but they don't display Project, Episode and Shot fields.
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name],['episode.Episode.name', 'is', episode_name]], ['code', 'sg_sequence.Sequence.sg_status_list']) sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list']) How do I return a query result that returns ALL the Project, Episode and Shot fields together?
Thank you in advance.
— Reply to this email directly, view it on GitHub https://github.com/shotgunsoftware/python-api/issues/273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAULRSZJ427P2ZCOR334COTWNBZ7FANCNFSM6AAAAAAS5GSCZU. You are receiving this because you are subscribed to this thread.
I just tried that:
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list', 'episode.Episode.name', 'project.Project.name' ])
No fields from Episode are returned. Only fields from Shot and only the Project name.
{'type': 'Shot', 'id': 8341, 'code': 'blahcode', 'sg_sequence.Sequence.sg_status_list': 'blahstatus', 'project.Project.name': 'SuperStickman'}
I tried this as well:
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name],['episode.Episode.name', 'is', episode_name]], ['code', 'sg_sequence.Sequence.sg_status_list', 'episode.Episode.name', 'project.Project.name' ] )
But it returns with an error:
shotgun_api3.shotgun.Fault: API read() Shot.episode.Episode.name doesn't exist:
{"path"=>"episode.Episode.name", "relation"=>"is", "values"=>["Stic-101"]}
I guess your Shot was not linked to an Episode.
Just add “episode” to the list of fields to return to double check: if empty then the Shot is not linked to an episode.
If the episode is set on the Sequence, you can get it with sg_sequence.Sequence.episode
, and its field values with sg_sequence.Sequence.episode.Episode.code
Check your SG schema for exact field values.
Cheers.
On 13 Dec 2022, at 15:22, David Marceau @.***> wrote:
I just tried that:
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list', 'episode.Episode.name', 'project.Project.name' ]) No fields from Episode are returned. Only fields from Shot and only the Project name.
{'type': 'Shot', 'id': 8341, 'code': 'blahcode', 'sg_sequence.Sequence.sg_status_list': 'blahstatus', 'project.Project.name': 'SuperStickman'} — Reply to this email directly, view it on GitHub https://github.com/shotgunsoftware/python-api/issues/273#issuecomment-1348675518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAULRSYD7S3375OOQCWLQPTWNCBEBANCNFSM6AAAAAAS5GSCZU. You are receiving this because you commented.
Much appreciated. Thanks you will try those.
The shot is not linked to an episode.
BINGO:
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list', 'sg_sequence.Sequence.episode', 'sg_sequence.Sequence.episode.Episode.code' ] )
Returns:
{'type': 'Shot', 'id': 8345, 'code': 'blahcodes1', 'sg_sequence.Sequence.sg_status_list': 'blahstatus2', 'sg_sequence.Sequence.episode': {'id': 400, 'name': 'Stic-101', 'type': 'Episode'}, 'sg_sequence.Sequence.episode.Episode.code': 'Stic-101'}
Thank you. We've got what we need with this. :)
You're a super-hero monkeydev.
How do I fetch the task name within this query as well?
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list', 'sg_sequence.Sequence.episode', 'sg_sequence.Sequence.episode.Episode.code', 'task.Task.name' ] )
I tried to fetch it but it's empty as well. Not linked as you mentioned?
This is interesting, is there a way to use this style of syntax to extract specific fields for list relationships too? Say I want to query Assets and also pull out additional fields for their related shots, and sequences.
Say I make this query: sg.find_one('Asset', [['code', 'is', 'sample_asset']], ["id", "code", "sg_status_list", "tasks", "shots"])
{
"type": "Asset",
"id": 1445,
"code": "sample_asset",
"sg_status_list": "wtg",
"tasks": [
{"id": 5868, "name": "Concept", "type": "Task"},
{"id": 5869, "name": "Model", "type": "Task"},
],
"shots": [
{"id": 1211, "name": "sample_shot_1", "type": "Shot"},
{"id": 1207, "name": "sample_shot_2", "type": "Shot"},
]
}
But I'd like to include additional fields in the Task
and Shot
lists. Is there a way to do that without having to make additional API calls specifically for Task and Shot?
@josh-mission I don't believe that is possible for multi-entity fields. see: https://community.shotgridsoftware.com/t/using-linked-fields-aka-bubbled-fields-in-api-requests/8697
Using the following variables:
I want to extract ALL the Project, Episode and Shot fields together.
I tried these two different ways, but they don't display Project, Episode and Shot fields.
How do I return a query result that returns ALL the Project, Episode and Shot fields together?
Thank you in advance.