Template Syntax

What is the syntax to use to create template keys which contain values for other fields from the Shot (or Sequence or Project entities) besides the default value used in the schema?


Hi Donna,

Could you give more explain of your question? Is it about schema field create? And the value means data or the field like list?



1 Like

im going to assume we are talking about template keys inside the templates.yml shotgun config…

maya_shot_render_path: ‘@shot_root/work/images/{task_name}/v{version}/{resolution}/{render_layer}/{project_name}{Sequence}{Shot}{task_name}{render_layer}_v{version}.%0{padding}d.{ext}’

this template key has a couple custom fields that are queried task_name, resolution, render_layer, padding

if we take a look at how render_layer for example is assigned:
type: str
shotgun_entity_type: PublishedFile
shotgun_field_name: sg_render_layer

we can see that render_layer is of type string, its part of the publishedFile entity, and the field name found in the SG database is sg_render_layer… that means a sg_render_layer field must be filled out within each publishedFile entity… and that field will then be passed to the template for any file that uses the template maya_shot_render_path.

we can also take a look at how I defined project_name, since your question was specific to fields from Project entities:
type: str
shotgun_entity_type: Project
shotgun_field_name: sg_project_prefix

Hope that helps… it’s really easy to query shot/asset/project fields, define them, and pass them to templates :wink:


apologies, I wasn’t very specific
I’ve been asked to create a directory structure & file naming like:
project name (the long project name)/sequence code (long name)/{sequence_short_code}{shot_number}/ {proj code}{seq short code}{shot num}{step}{version}.{ext}

In SG I created fields beyond the default ones that come with SG

However when I try to create keys for Project code and sequence short code in the templates, it says the contextis unable to resolve those values, however I am able to get the extra shot fields.

BTW I have figured out a work around since I first posted this.
But I’m wondering why when creating a new file under a lighting context (the shot_step) that I seem to be unable to get values for other fields the Project and Sequence entities.

1 Like

I’m asking because when I’m in a shot_step context. new_file errors saying it can not query values for Project or Sequence.

1 Like

Does your schema match your templates? That’s the important thing here.
Make sure you’ve set up schema so that the folders it’s generating match that of the templates.

If you’re not sure, I’m happy to take a look at your schema and templates for you. You can either attach it here or if your not comfortable sharing it publically then you can message me directly or put in a support ticket and then I can feedback here with any suggestions.


1 Like

Just posting back the relevant messages from our private conversation for the sake anyone else who follows this thread:

Just took a look at your config.

Based on the error I think the issue originally was that your sequence.yml had sq_{code}”, but your maya_shot_work template was sg_{Sequence_name}/... it should have just been {Sequence}.

Though I’m a bit confused as your error message seems to be suggesting that the template is different from that which you posted originally.




I see you fixed it by just not using the sequence, but I think if you correct the sequence folder in the template to be just {Sequence} then it should work.


1 Like

[By @donna]

Hi! Thanks you for help. Apologies for not responding sooner. I figured things out.
There were quite a few problems. The first was I didn’t understand that the ‘paths’ in the template.yml had to use the ‘Special’ keys which corresponded to the exact schema/folder ymls and that I couldn’t use a shot query key for the path definition.
Secondly, I figure out that I couldn’t have query keys that were duplicates of the fields used in the schema ymls. Ex
in Shot.yml if I had:

type: “shotgun_entity”
name: “sg_shortcode”
entity_type: “Shot”
filters: [ { “path”: “sg_sequence”, “relation”: “is”, “values”: [ “$sequence” ] } ]

And in the templates.yml I had

    type: str

    type: str
    shotgun_entity_type: Shot
    shotgun_field_name: code

    type: str
    shotgun_entity_type: Shot
    shotgun_field_name: sg_shortcode

The ‘shot_code’ key wasnt allowed because it was the same field queried in the Shot.yml

In the end I didn’t realize the the scehma path definitions were so tied to those ‘Special’ keys in the templates.yml and had to be used in the templates.yml path definitions.

Thanks for your help!

1 Like