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

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/scene_operation_tk-maya.py 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}/scene_operation_tk-maya.py ({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!

5 Likes