Different templates key per DCC depending on task

I need to use different templates key in Photoshop, depending on the task.

Basically, I want Photoshop to save the .psd file in a different template path with a different template file name if the user save in a list of specific tasks.

It seems to me templates keys are chosen depending on the entity type (wether we are in a shot or asset context). Is there a way to chose the templates key used to save files depending on the task?



Hi Ben –

The Toolkit Pipeline Configuration is organized by environment, and in the Default Config, our environments are indeed based on entity – there are different environments for pipeline steps on Assets and on Shots.

You can certainly customize the environments in your config. There are a few steps involved:

  • In config/core/templates.yml, create the extra templates you need.
  • If you’re writing to different paths, you’ll also need to modify your schema to create folders on disk for the different paths.
  • Create environment config files for each of the new environments in config/env. For example, if you had different environments for matte painting and paint fix, you might have config/env/matte_painting.yml and config/env/paint_fix.yml or something to that effect. You can copy asset_step.yml as a starting point, then modify the settings relevant to your new templates.
  • Finally, there is a core hook called pick_environment that holds the logic for determining which environment a user is at a given time. You’ll want to customize this core hook to include logic for your new environments.

So, that would be the formal way to do it. I wonder though if there might be a simpler, albeit slightly hackier way: Workfiles2 has a hook called scene_operation that contains the logic for opening a file, saving a file, etc. I believe you could take over this hook (there are actually DCC-specific copies of it, so you’d want to take over scene_operation_tk-photoshopcc.py specifically, and add the custom logic there to write the files where you want them to go. I say hacky because users will see a file path/name in the Shotgun -> File Save dialog, but the file will actually be saved to a different location.


Hi tannaz,
Thanks for your answer.

The second solution using scene_operation_tk-photoshopcc.py looks a bit too “hacky” for me, I’d rather have a very clean and easy to read config, using templates.

I tried the first solution and got it working (how to down there if anyone wants to know).
I have some questions:

In pick_environment.py, I added two new return possibilities: shot_sourceimages and asset_sourceimages:
if context.task[‘name’] == ‘shading’…
Is there a way to change pick_environment.py so that those environments are only chosen if we are inside of Shotgun Integration for Photoshop?
Right now, those new environments are also picked if I am inside of Maya. I can handle this by configuring those environments for very DCC, but this is a lot of “hacking” to keep a normal config on other DCC and this is pretty dangerous if we decide later to add a new DCC and forget about this as those two environments would not be configured on it.

What I did:

:diamonds: In templates.yml I created the templates I needed

:diamonds: In pick_environment.py, I added two new return possibilities: shot_sourceimages and asset_sourceimages:
if context.task[‘name’] == ‘shading’…

:diamonds: I modified all the files where I could find references to the nevironments asset_step and shot_step to use the correct templates keys for my new environments:

tk-photoshopcc.yml: ‘settings.tk-photoshopcc.shot_step_sourceimages’
tk-photoshopcc.yml: ‘settings.tk-photoshopcc.asset_step_sourceimages’

snapshot: ‘@settings.tk-multi-snapshot.photoshop.shot_step_sourceimages
snapshot: ‘@settings.tk-multi-snapshot.photoshop.asset_step_sourceimages

tk-multi-workfiles2: “@settings.tk-multi-workfiles2.photoshop.shot_step_sourceimage
tk-multi-workfiles2: “@settings.tk-multi-workfiles2.photoshop.asset_step_sourceimage”

tk-multi-publish2: “@settings.tk-multi-publish2.photoshop.shot_step_sourceimages
tk-multi-publish2: “@settings.tk-multi-publish2.photoshop.asset_step_sourceimage

      location: "@apps.tk-multi-about.location"
      location: "@apps.tk-multi-pythonconsole.location"
    tk-multi-loader2: "@settings.tk-multi-loader2.photoshop"
    tk-multi-publish2: "@settings.tk-multi-publish2.photoshop.asset_step_sourceimages"
    tk-multi-screeningroom: "@settings.tk-multi-screeningroom.rv"
    tk-multi-shotgunpanel: "@settings.tk-multi-shotgunpanel.photoshop"
    tk-multi-snapshot: "@settings.tk-multi-snapshot.photoshop.asset_step_sourceimages"
    tk-multi-workfiles2: "@settings.tk-multi-workfiles2.photoshop.asset_step_sourceimages"
  - {app_instance: tk-multi-workfiles2, name: File Open...}
  - {app_instance: tk-multi-snapshot, name: Snapshot...}
  - {app_instance: tk-multi-workfiles2, name: File Save...}
  - {app_instance: tk-multi-publish2, name: Publish...}
  location: '@engines.tk-photoshopcc.location'

Found a possible solution:

Calling sgtk.platform.current_engine().name will give the DCC name.


Looks like you beat me to the punch! Limiting your logic to the tk-photoshopcc engine is exactly the way to go. Glad you got it sorted, and thanks so much for sharing back your solution. Let us know if you hit any other snags as you go along.

1 Like