Specify hook in Maya settings

Hi !

I’m trying to define a hook in the Maya default settings for the tk-multi-workfiles2.

As I want it to work even if we don’t have an asset or shot context (like when I just opened Maya), I tried to edit the file like this in tk_config:

settings.tk-multi-workfiles2:
  my_hook: "path/to/my/hook/my_hook.py"

This hook contains a simple print to see if it works.

In Houdini this works well.
But not in Maya.
It’s like the default settings are not taken in account in Maya.

Any idea why ?

2 Likes

Hey,
you do lack some information in the explanation, but I’ll try to guess.
settings.tk-multiworkfiles2: here is just a definition, which then has to be referenced in order to have effect. The definitions here are not globals that would serve as fallback automatically.
You could reference this definition e.g. in project.yml, such that

tk-maya:
  apps:
    tk-multi-workfiles2: "@settings.tk-multi-workfiles2"

etc.
Maybe it is already linked to in a bunch of places, so you need to add it elsewhere too.

Otherwise it sounds like your approach to adding the hook is correct.

Btw, funnily we have also defined a hook after_load in multiple engines, which is executed once the program context is available (e.g. hou).
Strange there is no such hook already, right? It seems like the “correct” approach would be to wrap your integrations in toolkit apps/engines, instead of using hooks.
But this is a much simpler approach, in a sense.

5 Likes

Hi @mmoshev ! You’re greate !

I didn’t think about having a look at tk_maya.yml.

tk-maya.yml uses tk-multi-workfiles2: "@settings.tk-multi-workfiles2.launch_at_startup" in settings.tk-maya.project.

tk-houdini uses tk-multi-workfiles2: "@settings.tk-multi-workfiles2" in settings.tk-houdini.project

That’s why adding my hook in settings.tk-multi-workfiles2 worked for Houdini and not for Maya.
Adding it to settings.tk-multi-workfiles2.launch_at_startup make it work in Maya.

We can’t use the “correct” approach you mention because me created a hook override system letting us overriding hooks (and settings) from any package we want. Which gives us the ability to do it for a specific project and so on.

Thanks again for your answer, thanks to you I got a better understanding on how it works.

Cheers !

3 Likes