Maya - Launch a script inside the DCC when creating, opening or saving scene

Is there a way to launch a serie of functions inside maya whenever an artist create a new scene (once the folder creation has been done) or save, open or publish an existsing scene with Shotgun Open/Save ?

I would like to change some basic setup (like workspace path to sourceimages, for exemple) to be sure that paths are always setuped as long as the artists use Shotgun Integration in Maya.

I tried to read the Integrations Developer Guide page ( ) but it does not explain how to querry an action in SGI, or how to link an object with an action.
In the comments, this is written:

    The mapping between Shotgun objects and actions are kept in a different place
    (in the configuration) so at the point when this hook is called, the app
    has already established *which* actions are appropriate for this object.

The help page does not seem to explain much more.
Does anyone have an idea on how to do that kind of things?



Hi Ben –

The Workfiles2 app (tk-multi-workfiles2) has a hook called scene_operation that gives you the opportunity to add custom logic to the file new, open, save, and save-as operations.

So, if you want to take over the scene_operation hook for the tk-maya engine, you would:

  • Make a copy of install/app_store/tk-multi-workfiles2/<VERSION>/hooks/ in config/hooks.
  • Make your desired changes in the copied version of the file
  • Point your configuration to your copy by finding the tk-multi-workfiles2 app block in the tk-maya engine in the relevant environment(s), and setting the value of hook_scene_operation to {config}/ ({config} is a keyword that resolves to config/hooks in your pipeline configuration).

That is a very concise set of instructions for taking over a hook. I’m currently working on a guide that will go through the process in detail. If you need more info, let me know and I can clarify.

Some useful documents:

  • Environment Configuration Reference – I mentioned this in your other post, too – good description of how the config/env section of the Pipeline Config is structured.
  • Pipeline Tutorial – if you’re new to Toolkit and want a good overview of building out a simple pipeline, this is a great tutorial. It’ll go over all the details of the Pipeline Config, including several examples of taking over hooks.
  • Resolving Paths to Hooks – goes over {config} and other ways of pointing to hooks in the pipeline config.

Let me know if you have any other questions!


Hi Tannaz,
Thanks for your quick answer, it’s really clear!

I have a very hard time figuring out exactly what’s going on with all those hooks files, is there a map or flowchart of what functions call what py file with what hooks and when?



Hey Ben. Thanks - glad it was helpful.

There isn’t really a flowchart, and most of the hook system’s documentation is internal to the hooks themselves, so it can be a little hard to get your bearing.

I can provide these pointers:

  • When I’m curious about a given app’s hooks, I’ll usually just go to the apps hooks/ directory and see what’s available. Looking at the comments in each gives you an idea of what they do. There’s also a description of each of the hooks in the app’s info.yml file (as an example, you can see it in tk-multi-launchapp's info.yml here`).
  • Every Toolkit app has a documentation page, and you can get to them all from the Apps and Engines page. Often there’s more context there.

From there, if you want to know exactly when the hook is being called, you’ll have to browse through the app code a bit.

Hope that helps!


That helps a lot, thanks!

1 Like