Skip to content

Unable to specify correct filter to query and return all Project, Episode, and Shot fields together #273

Description

@omac777

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.

Activity

  1. monkeydev commented on Dec 13, 2022

    @monkeydev
  2. omac777 commented on Dec 13, 2022

    @omac777
    Author

    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'}
    
  3. omac777 commented on Dec 13, 2022

    @omac777
    Author

    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"]}
    
  4. monkeydev commented on Dec 13, 2022

    @monkeydev
  5. omac777 commented on Dec 13, 2022

    @omac777
    Author

    Much appreciated. Thanks you will try those.

    The shot is not linked to an episode.

  6. omac777 commented on Dec 13, 2022

    @omac777
    Author

    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.

  7. omac777 commented on Dec 13, 2022

    @omac777
    Author

    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?

  8. josh-mission commented on Jun 8, 2023

    @josh-mission

    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?

  9. blerrgh commented on Jun 11, 2023

    @blerrgh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions